X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Fvariables%2FStandardProceduralChildVariable.java;h=e96fd050a021ee1c9451efe19c1ee88d112d5855;hp=f133adee02e3c783b7e7fe5b8dc12ef93a6a4d5a;hb=2d97029aeaaf5d6a965eae98c1646eef29ae2f8b;hpb=25ff14b9cb52ccec8a7d6117f089d9ccbbb08ce2 diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java index f133adee0..e96fd050a 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/variables/StandardProceduralChildVariable.java @@ -1,8 +1,5 @@ package org.simantics.structural2.variables; -import gnu.trove.map.hash.THashMap; -import gnu.trove.set.hash.THashSet; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -16,7 +13,6 @@ import org.simantics.databoard.Bindings; import org.simantics.db.ReadGraph; import org.simantics.db.Resource; import org.simantics.db.Statement; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.NoSingleResultException; import org.simantics.db.layer0.function.All; @@ -39,9 +35,12 @@ import org.simantics.structural2.procedural.Terminal; import org.simantics.utils.datastructures.Pair; import org.slf4j.LoggerFactory; +import gnu.trove.map.hash.THashMap; + public class StandardProceduralChildVariable extends AbstractChildVariable { - private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StandardProceduralChildVariable.class); + private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(StandardProceduralChildVariable.class); + /* * Extension points * @@ -64,102 +63,6 @@ public class StandardProceduralChildVariable extends AbstractChildVariable { final private Map properties; final private List propertyIdentity; - public static class FixedConnection implements org.simantics.structural2.variables.Connection { - - final public Collection> cps = new ArrayList>(); - - final private Variable parent; - - public FixedConnection(Variable parent) { - this.parent = parent; - } - - @Override - public Collection getConnectionPoints(ReadGraph graph, Resource relationType) throws DatabaseException { - - Set result = new THashSet(); - for(Pair cp : cps) { - Variable component = cp.first == null ? parent : parent.getChild(graph, cp.first); - Variable cp2 = component.getPossibleProperty(graph, cp.second); - if(cp2 != null) - for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, cp.second, relationType)) { - result.add(desc.getVariable(graph)); - } - else - LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph)); - } - return result; - - } - - @Override - public Collection getConnectionPointURIs(ReadGraph graph, Resource relationType) throws DatabaseException { - - Set result = new THashSet(); - for(Pair cp : cps) { - Variable component = cp.first == null ? parent : parent.getChild(graph, cp.first); - Variable cp2 = component.getPossibleProperty(graph, cp.second); - if(cp2 != null) - for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, component, cp.second, relationType)) { - result.add(desc.getURI(graph)); - } - else - LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph)); - } - return result; - - } - - @Override - public Collection getConnectionPointDescriptors(ReadGraph graph, Resource relationType) throws DatabaseException { - - Set result = new THashSet(); - for(Pair cp : cps) { - Variable component = cp.first == null ? parent : parent.getChild(graph, cp.first); - Variable cp2 = component.getPossibleProperty(graph, cp.second); - if(cp2 != null) - result.addAll(ConnectionBrowser.flatten(graph, component, cp.second, relationType)); - else - LOGGER.warn("no cp " + cp.first + " for " + component.getURI(graph)); - } - return result; - - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((cps == null) ? 0 : cps.hashCode()); - result = prime * result - + ((parent == null) ? 0 : parent.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - FixedConnection other = (FixedConnection) obj; - if (cps == null) { - if (other.cps != null) - return false; - } else if (!cps.equals(other.cps)) - return false; - if (parent == null) { - if (other.parent != null) - return false; - } else if (!parent.equals(other.parent)) - return false; - return true; - } - - } - public StandardProceduralChildVariable(ReadGraph graph, Variable parent, VariableNode node, String name, Resource type, List properties, Collection conns) throws DatabaseException { super(node); assert name != null; @@ -208,7 +111,7 @@ public class StandardProceduralChildVariable extends AbstractChildVariable { for(Property p : properties) { String pn = graph.getRelatedValue(p.relation, L0.HasName, Bindings.STRING); if(p.value == null) { - Logger.defaultLogError("StandardProceduralChildVariable " + getURI(graph) + ": null value for property " + pn); + LOGGER.error("StandardProceduralChildVariable " + getURI(graph) + ": null value for property " + pn); } else if (p.value instanceof Expression) { Expression expression = (Expression)p.value; this.properties.put(pn, new StructuralProceduralExpressionPropertyVariable(graph, this, p.relation, expression.text) ); @@ -242,7 +145,7 @@ public class StandardProceduralChildVariable extends AbstractChildVariable { fc = new FixedConnection(parent); map.put(p, fc); } - fc.cps.addAll(cps); + fc.addAll(cps); } } for(Map.Entry entry : map.entrySet()) {