X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Fquery%2FMilestoneSpecQuery.java;fp=bundles%2Forg.simantics.charts%2Fsrc%2Forg%2Fsimantics%2Fcharts%2Fquery%2FMilestoneSpecQuery.java;h=40dbf0ed4e8bb99cc9c672c24643bba434a094e1;hp=cb19ae791c7b2ba47bc228af4282f504b140fd8a;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.charts/src/org/simantics/charts/query/MilestoneSpecQuery.java b/bundles/org.simantics.charts/src/org/simantics/charts/query/MilestoneSpecQuery.java index cb19ae791..40dbf0ed4 100644 --- a/bundles/org.simantics.charts/src/org/simantics/charts/query/MilestoneSpecQuery.java +++ b/bundles/org.simantics.charts/src/org/simantics/charts/query/MilestoneSpecQuery.java @@ -1,73 +1,73 @@ -/******************************************************************************* - * 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.charts.query; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.request.ResourceRead; -import org.simantics.db.exception.DatabaseException; -import org.simantics.event.ontology.EventResource; -import org.simantics.event.view.handler.MilestoneList; -import org.simantics.event.view.handler.MilestoneListQuery; -import org.simantics.layer0.Layer0; -import org.simantics.trend.impl.Milestone; -import org.simantics.trend.impl.MilestoneSpec; - -public class MilestoneSpecQuery extends ResourceRead { - - public MilestoneSpecQuery(Resource eventlog) { - super(eventlog); - } - - @Override - public MilestoneSpec perform(ReadGraph graph) throws DatabaseException { - MilestoneSpec result = new MilestoneSpec(); - result.init(); - result.baseline = -1; - Layer0 L0 = Layer0.getInstance(graph); - EventResource EVENT = EventResource.getInstance(graph); - - Resource experiment = resource; - Resource eventLog = graph.getPossibleObject(experiment, EVENT.IsEventProducerOf); - if (eventLog != null) { - MilestoneList ml = graph.sync( new MilestoneListQuery(eventLog) ); - for (Resource event : ml.milestones) - { - boolean isMilestone = graph.hasStatement(event, EVENT.Milestone); - boolean isHidden = graph.hasStatement(event, EVENT.Hidden); - boolean isBaseline = event.equals(ml.baseline); - if (!isMilestone && !isBaseline) continue; - - Double creationTime = graph.getPossibleRelatedValue(event, EVENT.HasTimestamp); - String milestoneLabel = graph.getPossibleRelatedValue(event, EVENT.Event_milestoneLabel); - String label = graph.getPossibleRelatedValue(event, L0.HasLabel); - - Milestone ms = new Milestone(); - ms.label = milestoneLabel==null ? "" : milestoneLabel; - ms.description = label==null ? "" : label; - ms.id = graph.getRelatedValue(event, L0.HasName); - ms.time = creationTime==null ? 0.0 : creationTime; - ms.hidden = isHidden; - if (isBaseline) result.baseline = result.milestones.size(); - result.milestones.add( ms ); - } - } - - return result; - } - - public Resource getEventLog() { - return resource; - } - - -} +/******************************************************************************* + * 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.charts.query; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.request.ResourceRead; +import org.simantics.db.exception.DatabaseException; +import org.simantics.event.ontology.EventResource; +import org.simantics.event.view.handler.MilestoneList; +import org.simantics.event.view.handler.MilestoneListQuery; +import org.simantics.layer0.Layer0; +import org.simantics.trend.impl.Milestone; +import org.simantics.trend.impl.MilestoneSpec; + +public class MilestoneSpecQuery extends ResourceRead { + + public MilestoneSpecQuery(Resource eventlog) { + super(eventlog); + } + + @Override + public MilestoneSpec perform(ReadGraph graph) throws DatabaseException { + MilestoneSpec result = new MilestoneSpec(); + result.init(); + result.baseline = -1; + Layer0 L0 = Layer0.getInstance(graph); + EventResource EVENT = EventResource.getInstance(graph); + + Resource experiment = resource; + Resource eventLog = graph.getPossibleObject(experiment, EVENT.IsEventProducerOf); + if (eventLog != null) { + MilestoneList ml = graph.sync( new MilestoneListQuery(eventLog) ); + for (Resource event : ml.milestones) + { + boolean isMilestone = graph.hasStatement(event, EVENT.Milestone); + boolean isHidden = graph.hasStatement(event, EVENT.Hidden); + boolean isBaseline = event.equals(ml.baseline); + if (!isMilestone && !isBaseline) continue; + + Double creationTime = graph.getPossibleRelatedValue(event, EVENT.HasTimestamp); + String milestoneLabel = graph.getPossibleRelatedValue(event, EVENT.Event_milestoneLabel); + String label = graph.getPossibleRelatedValue(event, L0.HasLabel); + + Milestone ms = new Milestone(); + ms.label = milestoneLabel==null ? "" : milestoneLabel; + ms.description = label==null ? "" : label; + ms.id = graph.getRelatedValue(event, L0.HasName); + ms.time = creationTime==null ? 0.0 : creationTime; + ms.hidden = isHidden; + if (isBaseline) result.baseline = result.milestones.size(); + result.milestones.add( ms ); + } + } + + return result; + } + + public Resource getEventLog() { + return resource; + } + + +}