-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.event.view.handler;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.VirtualGraph;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.event.ontology.EventResource;\r
-\r
-/**\r
- * This action fixes all MilestoneLabels of an EventLog.\r
- * \r
- * The label is derieved from the order number of an event. \r
- * \r
- * @author toni.kalajainen\r
- */\r
-public class CorrectMilestoneLabelsAction extends WriteRequest {\r
-\r
- Resource eventlog;\r
-\r
- public CorrectMilestoneLabelsAction(Resource eventlog, VirtualGraph vg) {\r
- super(vg);\r
- this.eventlog = eventlog;\r
- }\r
-\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
- EventResource EVENT = EventResource.getInstance(graph);\r
- MilestoneList ml = graph.sync( new MilestoneListQuery( eventlog ) );\r
- //System.out.println("Setting labels");\r
- if ( !ml.milestones.isEmpty() ) {\r
- for (int i=0; i<ml.milestones.size(); i++) {\r
- String lbl = Integer.toString( i+1 );\r
- Resource milestone = ml.milestones.get(i);\r
- graph.claimLiteral(milestone, EVENT.Event_milestoneLabel, lbl, Bindings.STRING);\r
- //System.out.println("Setting "+milestone+" to "+lbl);\r
- }\r
- }\r
-\r
- }\r
-\r
- public static void correctMilestoneLabels(WriteGraph graph, VirtualGraph vg, Collection<Resource> events) throws DatabaseException {\r
- Collection<Resource> eventlogs = graph.sync( new GetEventLogsQuery( events ) );\r
- for (Resource eventlog : eventlogs) {\r
- graph.syncRequest( new CorrectMilestoneLabelsAction(eventlog, vg) );\r
- }\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.event.view.handler;
+
+import java.util.Collection;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.VirtualGraph;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.event.ontology.EventResource;
+
+/**
+ * This action fixes all MilestoneLabels of an EventLog.
+ *
+ * The label is derieved from the order number of an event.
+ *
+ * @author toni.kalajainen
+ */
+public class CorrectMilestoneLabelsAction extends WriteRequest {
+
+ Resource eventlog;
+
+ public CorrectMilestoneLabelsAction(Resource eventlog, VirtualGraph vg) {
+ super(vg);
+ this.eventlog = eventlog;
+ }
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+ EventResource EVENT = EventResource.getInstance(graph);
+ MilestoneList ml = graph.sync( new MilestoneListQuery( eventlog ) );
+ //System.out.println("Setting labels");
+ if ( !ml.milestones.isEmpty() ) {
+ for (int i=0; i<ml.milestones.size(); i++) {
+ String lbl = Integer.toString( i+1 );
+ Resource milestone = ml.milestones.get(i);
+ graph.claimLiteral(milestone, EVENT.Event_milestoneLabel, lbl, Bindings.STRING);
+ //System.out.println("Setting "+milestone+" to "+lbl);
+ }
+ }
+
+ }
+
+ public static void correctMilestoneLabels(WriteGraph graph, VirtualGraph vg, Collection<Resource> events) throws DatabaseException {
+ Collection<Resource> eventlogs = graph.sync( new GetEventLogsQuery( events ) );
+ for (Resource eventlog : eventlogs) {
+ graph.syncRequest( new CorrectMilestoneLabelsAction(eventlog, vg) );
+ }
+ }
+
+}