Package org.apache.chemistry.opencmis.client.api

Examples of org.apache.chemistry.opencmis.client.api.Relationship


        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
        properties.put(PropertyIds.SOURCE_ID, source.getId());
        properties.put(PropertyIds.TARGET_ID, target.getId());

        ObjectId relId;
        Relationship result = null;

        try {
            relId = session.createRelationship(properties);
            result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
        } catch (Exception e) {
View Full Code Here


                // create documents
                Document doc1 = createDocument(session, testFolder, "doc1.txt", "doc1");
                Document doc2 = createDocument(session, testFolder, "doc2.txt", "doc2");

                // create relationship
                Relationship rel = createRelationship(session, "rel1", doc1, doc2);

                f = createResult(FAILURE, "Source document id does not match relationship source id!");
                addResult(assertEquals(doc1.getId(), rel.getSourceId().getId(), null, f));

                f = createResult(FAILURE, "Target document id does not match relationship target id!");
                addResult(assertEquals(doc2.getId(), rel.getTarget().getId(), null, f));

                // check the source document
                doc1.refresh();
                List<Relationship> doc1rels = doc1.getRelationships();

                f = createResult(FAILURE, "Source document has no relationships but must have at least one!");
                addResult(assertListNotEmpty(doc1rels, null, f));

                if (doc1rels != null) {
                    found = false;
                    for (Relationship r : doc1rels) {
                        if (rel.getId().equals(r.getId())) {
                            found = true;
                            break;
                        }
                    }

                    f = createResult(FAILURE,
                            "Newly created relationship not found in the relationships of the source document!");
                    addResult(assertIsTrue(found, null, f));
                }

                found = false;
                for (Relationship r : session.getRelationships(doc1, true, RelationshipDirection.SOURCE, null,
                        SELECT_ALL_NO_CACHE_OC)) {
                    if (rel.getId().equals(r.getId())) {
                        found = true;
                        break;
                    }
                }

                f = createResult(
                        FAILURE,
                        "Newly created relationship not found in the relationships returned by getObjectRelationships() for the source document!");
                addResult(assertIsTrue(found, null, f));

                // check the target document
                doc2.refresh();
                List<Relationship> doc2rels = doc2.getRelationships();

                f = createResult(FAILURE, "Target document has no relationships but must have at least one!");
                addResult(assertListNotEmpty(doc2rels, null, f));

                if (doc2rels != null) {
                    found = false;
                    for (Relationship r : doc2rels) {
                        if (rel.getId().equals(r.getId())) {
                            found = true;
                            break;
                        }
                    }

                    f = createResult(FAILURE,
                            "Newly created relationship not found in the relationships of the target document!");
                    addResult(assertIsTrue(found, null, f));
                }

                found = false;
                for (Relationship r : session.getRelationships(doc2, true, RelationshipDirection.TARGET, null,
                        SELECT_ALL_NO_CACHE_OC)) {
                    if (rel.getId().equals(r.getId())) {
                        found = true;
                        break;
                    }
                }
View Full Code Here

        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
        properties.put(PropertyIds.SOURCE_ID, source.getId());
        properties.put(PropertyIds.TARGET_ID, target.getId());

        ObjectId relId;
        Relationship result = null;

        try {
            relId = session.createRelationship(properties);
            result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
        } catch (Exception e) {
View Full Code Here

        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
        properties.put(PropertyIds.SOURCE_ID, source.getId());
        properties.put(PropertyIds.TARGET_ID, target.getId());

        ObjectId relId;
        Relationship result = null;

        try {
            relId = session.createRelationship(properties);
            result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
        } catch (Exception e) {
View Full Code Here

                // convert relationship objects
                List<Relationship> page = new ArrayList<Relationship>();
                if (relList.getObjects() != null) {
                    for (ObjectData rod : relList.getObjects()) {
                        Relationship relationship = new PersistentRelationshipImpl(getSession(), getObjectFactory()
                                .getTypeFromObjectData(rod), rod, ctxt);

                        page.add(relationship);
                    }
                }
View Full Code Here

        return getObject().getRelationships().size();
    }

    @Override
    public Object getDetailValueAt(int rowIndex, int columnIndex) {
        Relationship relationship = getObject().getRelationships().get(rowIndex);

        switch (columnIndex) {
        case 0:
            return relationship.getName();
        case 1:
            return relationship.getType().getId();
        case 2:
            return (relationship.getSourceId() == null ? "?" : relationship.getSourceId().getId());
        case 3:
            return (relationship.getTarget() == null ? "?" : relationship.getTarget().getId());
        }

        return null;
    }
View Full Code Here

        return getObject().getRelationships().size();
    }

    @Override
    public Object getDetailValueAt(int rowIndex, int columnIndex) {
        Relationship relationship = getObject().getRelationships().get(rowIndex);

        switch (columnIndex) {
        case 0:
            return relationship.getName();
        case 1:
            return relationship.getType().getId();
        case 2:
            return relationship;
        case 3:
            return relationship.getSourceId();
        case 4:
            return relationship.getTarget();
        }

        return null;
    }
View Full Code Here

            "doc1");
        Document doc2 = createDocument(session, testFolder, "doc2.txt",
            "doc2");

        // create relationship
        Relationship rel = createRelationship(session, "rel1", doc1,
            doc2);

        f = createResult(FAILURE,
            "Source document id does not match relationship source id!");
        addResult(assertEquals(doc1.getId(), rel.getSourceId().getId(),
            null, f));

        f = createResult(FAILURE,
            "Target document id does not match relationship target id!");
        addResult(assertEquals(doc2.getId(), rel.getTarget().getId(),
            null, f));

        // check the source document
        doc1.refresh();
        List<Relationship> doc1rels = doc1.getRelationships();

        f = createResult(FAILURE,
            "Source document has no relationships but must have at least one!");
        addResult(assertListNotEmpty(doc1rels, null, f));

        if (doc1rels != null) {
          found = false;
          for (Relationship r : doc1rels) {
            if (rel.getId().equals(r.getId())) {
              found = true;
              break;
            }
          }

          f = createResult(
              FAILURE,
              "Newly created relationship not found in the relationships of the source document!");
          addResult(assertIsTrue(found, null, f));
        }

        found = false;
        for (Relationship r : session.getRelationships(doc1, true,
            RelationshipDirection.SOURCE, null,
            SELECT_ALL_NO_CACHE_OC)) {
          if (rel.getId().equals(r.getId())) {
            found = true;
            break;
          }
        }

        f = createResult(
            FAILURE,
            "Newly created relationship not found in the relationships returned by getObjectRelationships() for the source document!");
        addResult(assertIsTrue(found, null, f));

        // check the target document
        doc2.refresh();
        List<Relationship> doc2rels = doc2.getRelationships();

        f = createResult(FAILURE,
            "Target document has no relationships but must have at least one!");
        addResult(assertListNotEmpty(doc2rels, null, f));

        if (doc2rels != null) {
          found = false;
          for (Relationship r : doc2rels) {
            if (rel.getId().equals(r.getId())) {
              found = true;
              break;
            }
          }

          f = createResult(
              FAILURE,
              "Newly created relationship not found in the relationships of the target document!");
          addResult(assertIsTrue(found, null, f));
        }

        found = false;
        for (Relationship r : session.getRelationships(doc2, true,
            RelationshipDirection.TARGET, null,
            SELECT_ALL_NO_CACHE_OC)) {
          if (rel.getId().equals(r.getId())) {
            found = true;
            break;
          }
        }
View Full Code Here

        properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
        properties.put(PropertyIds.SOURCE_ID, source.getId());
        properties.put(PropertyIds.TARGET_ID, target.getId());

        ObjectId relId;
        Relationship result = null;

        try {
            relId = session.createRelationship(properties);
            result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.client.api.Relationship

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.