use of org.jowidgets.cap.common.api.exception.ServiceException in project jo-client-platform by jo-source.
the class NodeAccessImpl method findNode.
@Override
public Node findNode(final Object beanTypeId, final Object nodeId) {
Assert.paramNotNull(beanTypeId, "beanTypeId");
Assert.paramNotNull(nodeId, "nodeId");
Node result = null;
final String beanTypeIdString = BeanTypeIdUtil.toString(beanTypeId);
for (final Node node : nodeIndex.get(IBean.ID_PROPERTY, nodeId)) {
if (beanTypeIdString.equals(node.getProperty(beanTypePropertyName))) {
if (result == null) {
result = node;
} else {
throw new ServiceException("More than one node found for the id '" + nodeId + "' and the type '" + beanTypeIdString + "'.");
}
}
}
return result;
}
use of org.jowidgets.cap.common.api.exception.ServiceException in project jo-client-platform by jo-source.
the class RelationshipAccessImpl method findRelationship.
@Override
public Relationship findRelationship(final Object beanTypeId, final Object nodeId) {
Assert.paramNotNull(beanTypeId, "beanTypeId");
Assert.paramNotNull(nodeId, "nodeId");
Relationship result = null;
final String beanTypeIdString = BeanTypeIdUtil.toString(beanTypeId);
for (final Relationship relationship : relationshipIndex.get(IBean.ID_PROPERTY, nodeId)) {
if (beanTypeIdString.equals(relationship.getProperty(beanTypePropertyName))) {
if (result == null) {
result = relationship;
} else {
throw new ServiceException("More than one relationship found for the id '" + nodeId + "' and the type '" + beanTypeIdString + "'.");
}
}
}
return result;
}
use of org.jowidgets.cap.common.api.exception.ServiceException in project jo-client-platform by jo-source.
the class LinkCreatorServiceImpl method createLink.
private IBeanDto createLink(final IBeanDto sourceBean, final IBeanDto linkedBean, final IBeanData additionalProperties, final IExecutionCallback executionCallback) {
final IBeanData decoratedBeanData = new DecoratedLinkBeanData(additionalProperties, linkedBean, sourceBean);
final IBeanDto linkBean = createBean(decoratedBeanData, linkCreatorService, executionCallback);
if (linkBean == null) {
throw new ServiceException("Can not create link for source: " + sourceBean + ", linked: " + linkedBean + ", additional properties: " + additionalProperties + ".");
}
if (linkBeanType.equals(linkedBeanAccess.getBeanType()) && linkedBean == null) {
return linkBean;
} else {
return linkedBean;
}
}
Aggregations