@Override
public PropertyInfo getPropertyInfo(ReadGraph graph) throws DatabaseException {
- throw new DatabaseException("PropertyInfo is not available");
+ throw new InvalidVariableException("PropertyInfo is not available");
}
@Override
String name = child.getPossiblePropertyValue(graph, Variables.NAME, Bindings.STRING);
if(rName.equals(name)) return child;
}
- throw new DatabaseException("Could not resolve child " + resource);
+ throw new MissingVariableException("Could not resolve child " + rName, resource);
}
protected Variable resolveChild(ReadGraph graph, GuidRVIPart part) throws DatabaseException {
String name = child.getPossiblePropertyValue(graph, Variables.NAME, Bindings.STRING);
if(rName.equals(name)) return child;
}
- throw new DatabaseException("Could not resolve child " + resource);
+ throw new MissingVariableException("Could not resolve child " + rName, resource);
}
protected Variable resolveProperty(ReadGraph graph, GuidRVIPart part) throws DatabaseException {
Variable parent = getParent(graph);
if (parent == null)
// TODO: consider using a more suitable exception here to better convey the situation.
- throw new MissingVariableException("no parent for variable " + this + " (URI=" + getPossibleURI(graph) + ")");
+ throw new MissingVariableException("no parent for variable " + this + " (URI=" + getPossibleURI(graph) + ")", getPossibleRepresents(graph));
RVI base = graph.syncRequest(new VariableRVIRequest(parent));
RVIPart part = getRVIPart(graph);
return new RVIBuilder(base).append(part).toRVI();
protected Variable getDomainProperty(ReadGraph graph, String name) throws DatabaseException {
Variable property = getPossibleDomainProperty(graph, name);
if(property == null)
- throw new MissingVariableException(getIdentifier() + ": Didn't find property " + name + ".");
+ throw new MissingVariableException(getIdentifier() + ": Didn't find property " + name + ".", getPossibleRepresents(graph));
return property;
}
@SuppressWarnings("unchecked")
@Override
- public <T> T getPropertyValue(ReadGraph graph, String name, Binding binding)
- throws DatabaseException {
- if(binding instanceof StringBinding) {
- StringBinding sb = (StringBinding)binding;
+ public <T> T getPropertyValue(ReadGraph graph, String name, Binding binding) throws DatabaseException {
+ if (binding instanceof StringBinding) {
+ StringBinding sb = (StringBinding) binding;
try {
- if(Variables.NAME.equals(name)) return (T)sb.create((String)checkNull(graph, getName(graph)));
- if(Variables.LABEL.equals(name)) return (T)sb.create((String)checkNull(graph, getLabel(graph)));
- if(Variables.URI.equals(name)) return (T)sb.create((String)checkNull(graph, getURI(graph)));
-// if(Variables.SERIALISED.equals(name)) return (T)sb.create((String)checkNull(graph, getSerialized(graph)));
- } catch(BindingException e) {
- throw new DatabaseException(e);
+ if (Variables.NAME.equals(name))
+ return (T) sb.create((String) checkNull(graph, getName(graph)));
+ if (Variables.LABEL.equals(name))
+ return (T) sb.create((String) checkNull(graph, getLabel(graph)));
+ if (Variables.URI.equals(name))
+ return (T) sb.create((String) checkNull(graph, getURI(graph)));
+ // if(Variables.SERIALISED.equals(name)) return
+ // (T)sb.create((String)checkNull(graph, getSerialized(graph)));
+ } catch (BindingException e) {
+ throw new org.simantics.db.exception.BindingException("Could not get value for property " + name + " with binding " + binding, e);
}
}
Variable property = getPossibleExtraProperty(graph, name);
return property.getValue(graph, binding);
property = getPossibleDomainProperty(graph, name);
if(property == null)
- throw new MissingVariableException("Didn't find property " + name + " for " + this + ".");
+ throw new MissingVariableException("Didn't find property " + name + " for " + this + ".", getPossibleRepresents(graph));
return property.getValue(graph, binding);
}
if(Variables.URI.equals(name)) return (T)sb.create((String)getURI(graph));
// if(Variables.SERIALISED.equals(name)) return (T)sb.create((String)getSerialized(graph));
} catch(BindingException e) {
- throw new DatabaseException(e);
+ throw new org.simantics.db.exception.BindingException("Could not get property value for " + name + " with binding " + binding, e);
}
}
Variable property = getPossibleExtraProperty(graph, name);
try {
setValue(graph, value, Bindings.getBinding(value.getClass()));
} catch (BindingConstructionException e) {
- throw new DatabaseException(e);
+ throw new org.simantics.db.exception.BindingException("Could not set " + String.valueOf(value) + " value for " + getRepresents(graph), e);
}
}
throws DatabaseException {
Variable child = getPossibleChild(graph, name);
if(child == null)
- throw new MissingVariableException(getURI(graph) + ": didn't find child " + name + " for " + getIdentifier() + ".");
+ throw new MissingVariableException(getURI(graph) + ": didn't find child " + name + " for " + getIdentifier() + ".", getPossibleRepresents(graph));
return child;
}
public Variable getProperty(ReadGraph graph, String name) throws DatabaseException {
Variable result = getPossibleProperty(graph, name);
if(result == null)
- throw new MissingVariableException(getClass().getSimpleName() + ": Didn't find property " + name + " for " + getPossibleURI(graph) + ".");
+ throw new MissingVariableException(getClass().getSimpleName() + ": Didn't find property " + name + " for " + getPossibleURI(graph) + ".", getPossibleRepresents(graph));
return result;
}
case '.': {
Variable parent = getParent(graph);
if(parent == null)
- throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").");
+ throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").", getPossibleRepresents(graph));
return parent.browse(graph, suffix.substring(1));
}
case '#': {
Variable property = getProperty(graph,
decodeString(suffix.substring(1, segmentEnd)));
if(property == null)
- throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").");
+ throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").", getPossibleRepresents(graph));
return property.browse(graph, suffix.substring(segmentEnd));
}
case '/': {
Variable child = getChild(graph,
decodeString(suffix.substring(1, segmentEnd)));
if(child == null)
- throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").");
+ throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").", getPossibleRepresents(graph));
return child.browse(graph, suffix.substring(segmentEnd));
}
default:
- throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").");
+ throw new MissingVariableException("Didn't find " + suffix + " for " + this + " (" + getPossibleURI(graph) + ").", getPossibleRepresents(graph));
}
}
Variable variable = browsePossible(graph, config);
if(variable == null)
throw new MissingVariableException("Didn't find a variable related to " +
- NameUtils.getSafeName(graph, config) + ".");
+ NameUtils.getSafeName(graph, config) + ".", config);
return variable;
}
try {
binding = Bindings.OBJECT.getContentBinding(value);
} catch (BindingException e) {
- throw new DatabaseException(e);
+ throw new org.simantics.db.exception.BindingException("Could not bind variant value " + String.valueOf(value) + " for " + getRepresents(graph), e);
}
return new Variant(binding, value);
}
if(Role.CHILD.equals(grp.getRole())) return resolveChild(graph, grp);
else if(Role.PROPERTY.equals(grp.getRole())) return resolveProperty(graph, grp);
}
- throw new DatabaseException("Unrecognized RVIPart: " + part);
+ throw new MissingVariableException("Unrecognized RVIPart: " + part, getPossibleRepresents(graph));
}
@Override
if(Role.CHILD.equals(grp.getRole())) return resolvePossibleChild(graph, grp);
else if(Role.PROPERTY.equals(grp.getRole())) return resolvePossibleProperty(graph, grp);
}
- throw new DatabaseException("Unrecognized RVIPart: " + part);
+ throw new MissingVariableException("Unrecognized RVIPart: " + part, getPossibleRepresents(graph));
}
@Override
public Datatype getDatatype(ReadGraph graph) throws DatabaseException {
- throw new DatabaseException("No data type.");
+ throw new InvalidVariableException("No data type.");
}
public Binding getDefaultBinding(ReadGraph graph) throws DatabaseException {
@Override
public Variable getPredicate(ReadGraph graph) throws DatabaseException {
- throw new DatabaseException(getClass().getSimpleName() + ": No predicate property for " + getPossibleURI(graph));
+ throw new MissingVariableException(getClass().getSimpleName() + ": No predicate property for " + getPossibleURI(graph), getPossibleRepresents(graph));
}
@Override
return null;
}
}
-
- @Override
- public Resource getPredicateResource(ReadGraph graph) throws DatabaseException {
- Variable predicate = getPredicate(graph);
- if(predicate == null) throw new DatabaseException(getClass().getSimpleName() + ": No predicate property for " + getPossibleURI(graph));
- return predicate.getRepresents(graph);
- }
-
+
+ @Override
+ public Resource getPredicateResource(ReadGraph graph) throws DatabaseException {
+ Variable predicate = getPredicate(graph);
+ if (predicate == null)
+ throw new MissingVariableException(getClass().getSimpleName() + ": No predicate property for " + getPossibleURI(graph), getPossibleRepresents(graph));
+ return predicate.getRepresents(graph);
+ }
+
@Override
public Resource getPossiblePredicateResource(ReadGraph graph) throws DatabaseException {
Variable predicate = getPossiblePredicate(graph);
Resource typeFromFunction = getTypeFromPossibleTypeFunction(graph, Layer0.getInstance(graph).Entity, getPossibleTypeFunction(graph));
if (typeFromFunction != null)
return typeFromFunction;
- } catch (Throwable t) {
+ } catch (DatabaseException t) {
return null;
}
Resource typeFromFunction = getTypeFromPossibleTypeFunction(graph, baseType, getPossibleTypeFunction(graph));
if (typeFromFunction != null)
return typeFromFunction;
- } catch (Throwable t) {
+ } catch (DatabaseException t) {
return null;
}