1 package org.simantics.diagram.profile;
3 import org.simantics.db.ReadGraph;
4 import org.simantics.db.Resource;
5 import org.simantics.db.common.NamedResource;
6 import org.simantics.db.common.request.ResourceRead;
7 import org.simantics.db.exception.DatabaseException;
8 import org.simantics.diagram.profile.ProfileActivityBean.Profile;
9 import org.simantics.diagram.stubs.DiagramResource;
10 import org.simantics.simulation.ontology.SimulationResource;
13 * @author Tuukka Lehtonen
16 class ProfileActivityBeanRequest extends ResourceRead<ProfileActivityBean> {
18 public ProfileActivityBeanRequest(Resource root) {
23 public ProfileActivityBean perform(ReadGraph graph) throws DatabaseException {
24 ProfileActivityBean bean = new ProfileActivityBean();
25 String rootUri = graph.getPossibleURI(resource);
29 for (NamedResource r : graph.syncRequest(new TopLevelProfiles(resource))) {
30 Profile prof = readProfile(graph, rootUri, r.getResource());
32 bean.topLevelProfiles.put(prof.relativeUri, prof);
35 DiagramResource DIA = DiagramResource.getInstance(graph);
36 Resource activeProfile = graph.getPossibleObject(resource, DIA.HasActiveProfile);
37 if (activeProfile != null) {
38 bean.activeProfile = Profiles.possiblyRelativeUri(graph, rootUri, activeProfile);
44 private static Profile readProfile(ReadGraph graph, String rootUri, Resource profile) throws DatabaseException {
45 Profile prof = new Profile();
46 prof.relativeUri = Profiles.possiblyRelativeUri(graph, rootUri, profile);
47 if (prof.relativeUri == null)
50 SimulationResource SIMU = SimulationResource.getInstance(graph);
51 for (Resource active : graph.getObjects(profile, SIMU.IsActive)) {
52 String euri = Profiles.possiblyRelativeUri(graph, rootUri, active);
54 prof.activeEntries.add(euri);