use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class SolrMatcherEvaluation method createNeedId.
public static String createNeedId(Dataset need) {
String title = "";
String description = "";
try {
DefaultNeedModelWrapper needModelWrapper = new DefaultNeedModelWrapper(need);
title = needModelWrapper.getTitles(NeedContentPropertyType.ALL).iterator().next();
title = title.replaceAll("[^A-Za-z0-9 ]", "_");
title = title.replaceAll("NOT", "_");
title = title.replaceAll("AND", "_");
title = title.replaceAll("OR", "_");
description = needModelWrapper.getSomeDescription(NeedContentPropertyType.ALL);
} catch (IncorrectPropertyCountException e) {
// do nothing
}
if (title.isEmpty()) {
throw new IllegalArgumentException("need has no title!!");
}
return title + "_" + (title + description).hashCode();
}
use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class SolrMatcherEvaluation method createAtomId.
public static String createAtomId(Dataset atom) {
String title = "";
String description = "";
try {
DefaultAtomModelWrapper atomModelWrapper = new DefaultAtomModelWrapper(atom);
title = atomModelWrapper.getAllTitles().iterator().next();
title = title.replaceAll("[^A-Za-z0-9 ]", "_");
title = title.replaceAll("NOT", "_");
title = title.replaceAll("AND", "_");
title = title.replaceAll("OR", "_");
description = atomModelWrapper.getSomeDescription();
} catch (IncorrectPropertyCountException e) {
// do nothing
}
if (title.isEmpty()) {
throw new IllegalArgumentException("atom has no title!!");
}
return title + "_" + (title + description).hashCode();
}
use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class LinkedDataWebController method getObjectOfPropertyAsString.
private String getObjectOfPropertyAsString(org.apache.jena.rdf.model.Model model, Property property) {
NodeIterator nodeIteratr = model.listObjectsOfProperty(property);
if (!nodeIteratr.hasNext()) {
return null;
}
String ret = nodeIteratr.next().asLiteral().getString();
if (nodeIteratr.hasNext()) {
throw new IncorrectPropertyCountException("found more than one property of cnt:bytes", 1, 2);
}
return ret;
}
use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class NeedModelWrapper method getContentPropertyObject.
private Node getContentPropertyObject(NeedContentPropertyType type, String propertyPath) {
Path path = PathParser.parse(propertyPath, DefaultPrefixUtils.getDefaultPrefixes());
Collection<Resource> nodes = getContentNodes(type);
if (nodes.size() != 1) {
throw new IncorrectPropertyCountException("expected exactly one occurrence of object for property path " + propertyPath, 1, nodes.size());
}
Node node = nodes.iterator().next().asNode();
return RdfUtils.getNodeForPropertyPath(getNeedModel(), node, path);
}
use of won.protocol.exception.IncorrectPropertyCountException in project webofneeds by researchstudio-sat.
the class RdfDatasetAttachmentConverter method getObjectOfPropertyAsString.
private String getObjectOfPropertyAsString(Model model, Property property) {
NodeIterator nodeIteratr = model.listObjectsOfProperty(property);
if (!nodeIteratr.hasNext())
return null;
String ret = nodeIteratr.next().asLiteral().getString();
if (nodeIteratr.hasNext()) {
throw new IncorrectPropertyCountException("found more than one property of cnt:bytes", 1, 2);
}
return ret;
}
Aggregations