Package javax.jcr.nodetype

Examples of javax.jcr.nodetype.NodeType


     * @return Xml representation of the specified {@link ItemDefinition def}.
     * @param document
     */
    public Element toXml(Document document) {
        Element elem = document.createElement(getElementName());
        NodeType dnt = getDeclaringNodeType();
        if (dnt != null) {
            elem.setAttribute(DECLARINGNODETYPE_ATTRIBUTE, dnt.getName());
        }
        elem.setAttribute(NAME_ATTRIBUTE, getName());
        elem.setAttribute(AUTOCREATED_ATTRIBUTE, Boolean.toString(isAutoCreated()));
        elem.setAttribute(MANDATORY_ATTRIBUTE, Boolean.toString(isMandatory()));
        elem.setAttribute(ONPARENTVERSION_ATTRIBUTE, OnParentVersionAction.nameFromValue(getOnParentVersion()));
View Full Code Here


     */
    public Element toXml(Document document) {
        Element report = document.createElement(NODETYPES_ELEMENT);
        // loop over the nodetypes to be returned in the report
        while (ntIter.hasNext()) {
            NodeType nt = ntIter.nextNodeType();
            Element ntDef = document.createElement(NODETYPE_ELEMENT);
            ntDef.setAttribute(NAME_ATTRIBUTE, nt.getName());
            ntDef.setAttribute(ISMIXIN_ATTRIBUTE, Boolean.toString(nt.isMixin()));
            ntDef.setAttribute(HASORDERABLECHILDNODES_ATTRIBUTE, Boolean.toString(nt.hasOrderableChildNodes()));

            // declared supertypes
            NodeType[] snts = nt.getDeclaredSupertypes();
            Element supertypes = DomUtil.addChildElement(ntDef, SUPERTYPES_ELEMENT, null);
            for (int i = 0; i < snts.length; i++) {
                DomUtil.addChildElement(supertypes, SUPERTYPE_ELEMENT, null, snts[i].getName());
            }

            // declared childnode defs
            NodeDefinition[] cnd = nt.getChildNodeDefinitions();
            for (int i = 0; i < cnd.length; i++) {
                if (cnd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(NodeDefinitionImpl.create(cnd[i]).toXml(document));
                }
            }

            // declared propertyDefs
            PropertyDefinition[] pd = nt.getPropertyDefinitions();
            for (int i = 0; i < pd.length; i++) {
                if (pd[i].getDeclaringNodeType().getName().equals(nt.getName())) {
                    ntDef.appendChild(PropertyDefinitionImpl.create(pd[i]).toXml(document));
                }
            }

            String primaryItemName = nt.getPrimaryItemName();
            if (primaryItemName != null) {
                ntDef.setAttribute(PRIMARYITEMNAME_ATTRIBUTE, primaryItemName);
            }
            report.appendChild(ntDef);
        }
View Full Code Here

     */
    public void testIfPrimaryNodeTypesAreSubtypesOfNTBase()
            throws RepositoryException {
        NodeTypeIterator types = manager.getPrimaryNodeTypes();
        while (types.hasNext()) {
            NodeType type = types.nextNodeType();
            assertTrue("Primary node type " + type.getName() +
                    " must inherit nt:base",
                    type.isNodeType("nt:base"));
        }
    }
View Full Code Here

                    getClass().getClassLoader().getResourceAsStream(resource));
            for (int ch = reader.read(); ch != -1; ch = reader.read()) {
                spec.append((char) ch);
            }

            NodeType type = manager.getNodeType(name);
            String current = getNodeTypeSpec(type);
            if (!System.getProperty("line.separator").equals("\n")) {
                current = normalizeLineSeparators(current);
            }
            String expected = normalizeLineSeparators(spec.toString());
View Full Code Here

         if (this.isRoot())
         { // root - no parent
            if (nodeDefinition == null)
            {
               NodeType required =
                  nodeTypeManager.getNodeType(locationFactory.createJCRName(Constants.NT_BASE).getAsString());
               InternalQName requiredName = sysLocFactory.parseJCRName(required.getName()).getInternalName();
               NodeDefinitionData ntData =
                  new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, false,
                     new InternalQName[]{requiredName}, null, true);
               this.nodeDefinition =
                  new NodeDefinitionImpl(ntData, nodeTypesHolder, nodeTypeManager, sysLocFactory,
View Full Code Here

         if (this.isRoot())
         { // root - no parent
            if (nodeDefinition == null)
            {
               NodeType required =
                  nodeTypeManager.getNodeType(locationFactory.createJCRName(Constants.NT_BASE).getAsString());
               InternalQName requiredName = sysLocFactory.parseJCRName(required.getName()).getInternalName();
               NodeDefinitionData ntData =
                  new NodeDefinitionData(null, null, true, true, OnParentVersionAction.ABORT, false,
                     new InternalQName[]{requiredName}, null, true);
               this.nodeDefinition =
                  new NodeDefinitionImpl(ntData, nodeTypesHolder, nodeTypeManager, sysLocFactory, session
View Full Code Here

        nodeTypes = new CndNodeTypeSource(CND_LOCATION + "validType.cnd");

        repoTypeManager.registerNodeTypes(nodeTypes);
        Name testNodeName = context.getValueFactories().getNameFactory().create(TestLexicon.Namespace.URI, "testType");

        NodeType nodeType = repoTypeManager.getNodeType(testNodeName);
        assertThat(nodeType, is(notNullValue()));
        assertThat(nodeType.isMixin(), is(true));
        assertThat(nodeType.hasOrderableChildNodes(), is(true));
        assertThat(nodeType.getDeclaredSupertypes().length, is(2));
        assertThat(nodeType.getDeclaredChildNodeDefinitions().length, is(1));
        JcrNodeDefinition childNode = (JcrNodeDefinition)nodeType.getDeclaredChildNodeDefinitions()[0];
        assertThat(childNode.getName(), is("dnatest:namespace"));
        assertThat(childNode.getDefaultPrimaryType().getName(), is("dna:namespace"));
        assertThat(childNode.getRequiredPrimaryTypes().length, is(1));
        assertThat(childNode.getRequiredPrimaryTypes()[0].getName(), is("dna:namespace"));
        assertThat(childNode.allowsSameNameSiblings(), is(false));
        assertThat(childNode.isMandatory(), is(false));

        assertThat(nodeType.getDeclaredPropertyDefinitions().length, is(1));
        JcrPropertyDefinition property = (JcrPropertyDefinition)nodeType.getDeclaredPropertyDefinitions()[0];
        assertThat(property.getName(), is("*"));
        assertThat(property.getRequiredType(), is(PropertyType.STRING));
        assertThat(property.getValueConstraints().length, is(3));
        assertThat(property.getValueConstraints()[0], is("foo"));
        assertThat(property.getValueConstraints()[1], is("bar"));
View Full Code Here

      throw new NullPointerException();
    }

    //
    TypeMapper typeMapper = domain.getTypeMapper(clazz);
    NodeType nodeType = sessionWrapper.getNodeType(typeMapper.getNodeDef().getPrimaryNodeTypeName());
    TransientContextState state = new TransientContextState(this, nodeType);

    //
    ObjectContext ctx = new ObjectContext(typeMapper, state);
View Full Code Here

    Node parent = sessionWrapper.getParent(node);
    return findByNode(Object.class, parent);
  }

  public void nodeRead(Node node) throws RepositoryException {
    NodeType nodeType = node.getPrimaryNodeType();
    String nodeTypeName = nodeType.getName();
    TypeMapper mapper = domain.getTypeMapper(nodeTypeName);
    if (mapper != null) {
      String id = node.getUUID();
      ObjectContext ctx = contexts.get(id);
      if (ctx == null) {
View Full Code Here

      log.trace("Could not find mapper for node type {}", nodeTypeName);
    }
  }

  public void nodeAdded(Node node, ObjectContext ctx) throws RepositoryException {
    NodeType nodeType = node.getPrimaryNodeType();
    String nodeTypeName = nodeType.getName();
    TypeMapper mapper = domain.getTypeMapper(nodeTypeName);
    if (mapper != null) {
      String id = node.getUUID();
      if (contexts.containsKey(id)) {
        String msg = "Attempt to replace an existing context " + ctx + " with id " + id;
View Full Code Here

TOP

Related Classes of javax.jcr.nodetype.NodeType

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.