X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Fview%2Fhandler%2FCorrectMilestoneLabelsAction.java;fp=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Fview%2Fhandler%2FCorrectMilestoneLabelsAction.java;h=a9783b22ae8488d5d3ec46a57843eef66075dcd8;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.event/src/org/simantics/event/view/handler/CorrectMilestoneLabelsAction.java b/bundles/org.simantics.event/src/org/simantics/event/view/handler/CorrectMilestoneLabelsAction.java new file mode 100644 index 000000000..a9783b22a --- /dev/null +++ b/bundles/org.simantics.event/src/org/simantics/event/view/handler/CorrectMilestoneLabelsAction.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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 events) throws DatabaseException { + Collection eventlogs = graph.sync( new GetEventLogsQuery( events ) ); + for (Resource eventlog : eventlogs) { + graph.syncRequest( new CorrectMilestoneLabelsAction(eventlog, vg) ); + } + } + +}