Package org.ontoware.rdfreactor.generator.java

Examples of org.ontoware.rdfreactor.generator.java.JProperty


                    } else {
                        JClass domainClass = jm.getMapping(domain.getResource());
                        assert domainClass != null : "found no JClass for "
                                + rp.getAllDomain_asList().get(0).getResource();
                       
                        JProperty jprop = new JProperty(domainClass, propertyName,
                                (URI)rp.getResource());
                        // wire
                        log.debug("Adding property '" + jprop.getName() + "' to '"
                                + domainClass.getName() + "'");
                        jprop.getJClass().getProperties().add(jprop);
                        jprop.setComment(rp.getAllComment_asList().get(0));
                       
                        for(Class range : rp.getAllRange_asList()) {
                            if(owlClasses.contains(range
                                    .castTo(org.ontoware.rdfreactor.schema.owl.OwlClass.class)))
                                jprop.addType(jm.getMapping(range.getResource()));
                        }
                        jprop.fixRanges(jm);
                       
                        // figure out cardinality
                       
                        ClosableIterator<Statement> it = m.findStatements(Variable.ANY,
                                OWL.onProperty, rp.getResource());
                        while(it.hasNext()) {
                            Statement stmt = it.next();
                            org.ontoware.rdf2go.model.node.Resource restrictionResource = stmt
                                    .getSubject();
                            OWL_Protege_NRL_Restriction restriction = OWL_Protege_NRL_Restriction
                                    .getInstance(m, restrictionResource);
                           
                            int min = restriction.getAllMinCardinality_asList().get(0);
                            log.debug("Found minrestriction on " + rp + " minCard = " + min);
                            if(min != -1)
                                jprop.setMinCardinality(min);
                            int max = restriction.getAllMaxCardinality_asList().get(0);
                            log.debug("Found maxrestriction on " + rp + " maxCard = " + max);
                            if(max != -1)
                                jprop.setMaxCardinality(max);
                        }
                        it.close();
                    }
                }
            }
View Full Code Here


       
        // obtain a nice Java-conform name which has not yet been used
        String propertyName = JavaNamingUtils.toBeanName(property,
                domainClass.getUsedPropertyNames());
        assert propertyName != null;
        JProperty jprop = new JProperty(domainClass, propertyName, (URI)property.getResource());
        // carry over the comment from RDF to Java, might be null
        jprop.setComment(Utils.toJavaComment(property.getAllComment_asList()));
        log.debug("PROPERTY Adding '" + jprop.getName() + "' to '" + domainClass.getName() + "'");
        jprop.getJClass().getProperties().add(jprop);
       
        // process range information
        log.debug("PROPERTY checking ranges...");
        for(Class range : property.getAllRange_asList()) {
            log.debug("range is " + range);
            jprop.addType(jm.getMapping(range.getResource()));
        }
        if(property.getAllRange_asList().size() == 0) {
            // if no range is given, set to ontology root class (rdfs:Class or
            // owl:Class)
            jprop.addType(jm.getRoot());
        }
       
        // process cardinality constraints (convert this property to an OWL
        // restriction)
        OWL_Protege_NRL_Restriction restriction = (OWL_Protege_NRL_Restriction)property
                .castTo(OWL_Protege_NRL_Restriction.class);
        assert restriction != null;
       
        Integer card = restriction.getCardinality();
        Integer minCard = restriction.getMinCardinality();
       
        Integer maxCard = restriction.getMaxCardinality();
        int min = -1;
        int max = -1;
       
        if(minCard != null) {
            min = minCard;
            log.debug("Found minrestriction on " + property + " minCard = " + min);
        } else if(card != null) {
            log.debug("Found card.restriction on " + property + " card = " + min);
            min = card;
        }
        jprop.setMinCardinality(min);
       
        if(maxCard != null) {
            max = maxCard;
            log.debug("Found maxrestriction on " + property + " maxCard = " + max);
        } else if(card != null) {
            log.debug("Found card.restriction on " + property + " card = " + min);
            max = card;
        }
        jprop.setMaxCardinality(max);
       
        if(min != -1 || max != -1) {
            domainClass.cardinalityexception = true;
            log.debug("added card.exception in class " + domainClass.getName());
        }
View Full Code Here

    JClass _resource = new JClass(JPackage.RDFSCHEMA, JPackage.RDFSCHEMA
        .getName()
        + ".Resource", RDFS.Resource);
    jm.addMapping(RDFS.Resource, _resource);
    _resource.getProperties().add(
        new JProperty(_resource, "label", RDFS.label));
    _resource.getProperties().add(
        new JProperty(_resource, "comment", RDFS.comment));
    _resource.getProperties().add(
        new JProperty(_resource, "type", RDF.type));
    _resource.getProperties().add(
        new JProperty(_resource, "member", RDFS.member));
    jm.addMapping(RDFS.Resource, _resource);

    // owl mapping
    final String owl = "org.ontoware.rdfreactor.schema.owl";
View Full Code Here

    // deprecated
    // JProperty jprop1 = new JProperty("age", new
    // JAttribute(Integer.class),
    // URIUtils.createURI("schema://age"), 1, 1);
    // jc1.getProperties().add(jprop1);
    JProperty jprop2 = new JProperty(jc1, "friend", new URIImpl("urn:ex:knows"), JProperty.NOT_SET, JProperty.NOT_SET );
    jprop2.setComment("A persons knows other persons. They can be considered friends.");
    jprop2.addType(jc1);
    jc1.getProperties().add(jprop2);
    SourceCodeWriter.write(jm, new File(outdir), SourceCodeWriter.TEMPLATE_CLASS,"Prefix");

  }
View Full Code Here

TOP

Related Classes of org.ontoware.rdfreactor.generator.java.JProperty

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.