import org.simantics.db.Resource;
import org.simantics.db.common.procedure.adapter.TransientCacheListener;
import org.simantics.db.common.request.IndexRoot;
+import org.simantics.db.common.utils.NameUtils;
import org.simantics.db.exception.DatabaseException;
import org.simantics.db.layer0.variable.Variable;
import org.simantics.layer0.Layer0;
Object oldGraph = sclContext.get("graph");
CompileStructuralValueRequest request = new CompileStructuralValueRequest(graph, context);
try {
- Function1<Variable,Object> exp = graph.syncRequest(request, TransientCacheListener.<Function1<Variable,Object>>instance());
+ Function1<Object,Object> exp = graph.syncRequest(request, TransientCacheListener.instance());
sclContext.put("graph", graph);
return exp.apply(context);
} catch (Throwable t) {
- throw new DatabaseException("Compiling structural value request for component=" + request.component + ", literal=" + request.literal + " and relation " + request.relation + " failed!", t);
+ String componentName = NameUtils.getSafeName(graph, request.component);
+ String literalName = NameUtils.getSafeName(graph, request.literal);
+ String relationName = NameUtils.getSafeName(graph, request.relation);
+ StringBuilder sb = new StringBuilder("Compiling structural value request for component ")
+ .append(componentName).append(" ").append(request.component).append(" , literal ")
+ .append(literalName).append(" ").append(request.literal).append(" and relation ")
+ .append(relationName).append(" ").append(request.relation).append(" failed!");
+ throw new DatabaseException(sb.toString(), t);
} finally {
sclContext.put("graph", oldGraph);
}
}
+ public static Function1<Object, Object> compile(ReadGraph graph, Resource s, Resource o, Resource p) throws DatabaseException {
+ return graph.syncRequest(new CompileStructuralValueRequest(s, o, p), TransientCacheListener.instance());
+ }
+
@Override
protected String getExpressionText(ReadGraph graph)
throws DatabaseException {
public int hashCode() {
final int prime = 31;
int result = 1;
+ result = prime * result + ((relation == null) ? 0 : relation.hashCode());
result = prime * result + ((component == null) ? 0 : component.hashCode());
result = prime * result + ((literal == null) ? 0 : literal.hashCode());
return result;
if (getClass() != obj.getClass())
return false;
CompileStructuralValueRequest other = (CompileStructuralValueRequest) obj;
+ if (relation == null) {
+ if (other.relation != null)
+ return false;
+ } else if (!relation.equals(other.relation))
+ return false;
if (component == null) {
if (other.component != null)
return false;