Search in sources :

Example 1 with ServiceException

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;
}
Also used : ServiceException(org.jowidgets.cap.common.api.exception.ServiceException) Node(org.neo4j.graphdb.Node)

Example 2 with ServiceException

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;
}
Also used : ServiceException(org.jowidgets.cap.common.api.exception.ServiceException) Relationship(org.neo4j.graphdb.Relationship)

Example 3 with ServiceException

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;
    }
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ServiceException(org.jowidgets.cap.common.api.exception.ServiceException) IBeanData(org.jowidgets.cap.common.api.bean.IBeanData)

Aggregations

ServiceException (org.jowidgets.cap.common.api.exception.ServiceException)3 IBeanData (org.jowidgets.cap.common.api.bean.IBeanData)1 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)1 Node (org.neo4j.graphdb.Node)1 Relationship (org.neo4j.graphdb.Relationship)1