Exemplo n.º 1
0
 @Test
 public void testWithoutParent() throws Exception {
   DocumentType type = schemaManager.getDocumentType("Document");
   JsonAssert json = jsonAssert(type);
   json.properties(5);
   json.has("parent").isNull();
 }
Exemplo n.º 2
0
  // "readonly" meaningful for proxies and versions, used for import
  private Document newDocument(Node node, boolean readonly) {
    if (node == null) {
      // root's parent
      return null;
    }

    Node targetNode = null;
    String typeName = node.getPrimaryType();
    if (node.isProxy()) {
      Serializable targetId = node.getSimpleProperty(Model.PROXY_TARGET_PROP).getValue();
      if (targetId == null) {
        throw new NoSuchDocumentException("Proxy has null target");
      }
      targetNode = session.getNodeById(targetId);
      typeName = targetNode.getPrimaryType();
    }
    SchemaManager schemaManager = Framework.getLocalService(SchemaManager.class);
    DocumentType type = schemaManager.getDocumentType(typeName);
    if (type == null) {
      throw new NoSuchDocumentException("Unknown document type: " + typeName);
    }

    if (node.isProxy()) {
      // proxy seen as a normal document
      Document proxy = new SQLDocumentLive(node, type, this, false);
      Document target = newDocument(targetNode, readonly);
      return new SQLDocumentProxy(proxy, target);
    } else if (node.isVersion()) {
      return new SQLDocumentVersion(node, type, this, readonly);
    } else {
      return new SQLDocumentLive(node, type, this, false);
    }
  }
Exemplo n.º 3
0
 @Test
 public void test() throws Exception {
   DocumentType type = schemaManager.getDocumentType("Folder");
   JsonAssert json = jsonAssert(type);
   json.properties(5);
   json.has("entity-type").isEquals("docType");
   json.has("name").isEquals("Folder");
   json.has("parent").isEquals("Document");
   json.has("facets").contains("Folderish");
   json = json.has("schemas").length(2);
   json.childrenContains("entity-type", "schema", "schema");
   json.childrenContains("name", "common", "dublincore");
 }
Exemplo n.º 4
0
 public String[] getSuperTypes(String typeName) {
   try {
     SchemaManager schemaMgr = Framework.getService(SchemaManager.class);
     DocumentType type = schemaMgr.getDocumentType(typeName);
     if (type == null) {
       return null;
     }
     type = (DocumentType) type.getSuperType();
     List<String> superTypes = new ArrayList<String>();
     while (type != null) {
       superTypes.add(type.getName());
       type = (DocumentType) type.getSuperType();
     }
     return superTypes.toArray(new String[superTypes.size()]);
   } catch (Exception e) {
     log.error("Failed to lookup the SchemaManager service", e);
     return new String[0];
   }
 }
Exemplo n.º 5
0
  @Test
  public void testDoctypesAvailability() throws ClientException {

    String[] doctypes =
        new String[] {
          Deliverable.DOCTYPE,
          DeployedDeliverable.DOCTYPE,
          Endpoint.DOCTYPE,
          IntelligentSystem.DOCTYPE,
          IntelligentSystemTreeRoot.DOCTYPE,
          Repository.DOCTYPE,
          InformationService.DOCTYPE,
          ServiceImplementation.DOCTYPE,
          SoftwareComponent.DOCTYPE,
          SystemTreeRoot.DOCTYPE,
          TaggingFolder.DOCTYPE
        };

    for (String doctype : doctypes) {
      Assert.assertNotNull(
          "Doctype " + doctype + " must exist", schemaManager.getDocumentType(doctype));
    }
  }