Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Property


    //////////////////////////////////////////////////
    // transfer any preexisting attributes, and then remove all properties from
    // pre-existing ontRes so just the new OntModel gets added.
    if ( ontRes != null ) {
      for ( Statement st : prexistStatements ) {
        Property prd = st.getPredicate();

        //
        // Do not tranfer pre-existing/pre-assigned-above attributes
        //
        String newValue = newValues.get(prd.getURI());
        if ( newValue == null || newValue.trim().length() == 0 ) {
          log.info("  Transferring: " +st.getSubject()+ " :: " +prd+ " :: " +st.getObject());
          newOntModel.add(ont_, prd, st.getObject());
        }
        else {
          log.info(" Removing pre-existing values for predicate: " +prd+ " because of new value " +newValue);
          newOntModel.removeAll(ont_, prd, null);
        }
      } 
     
     
      if ( ! createOntologyResult.isPreserveOriginalBaseNamespace() ) {
       
        //
        // Only, when we're creating a new model, ie., per the new namespace, do the following removals.
        // (If we did this on a model with the same original namespace, we would remove the owl:Ontology
        // entry altogether and get an "rdf:Description" instead.
        //
       
        log.info("Removing original OWL.Ontology individual");
        ontRes.removeProperties();
        // TODO the following may be unnecesary but doesn't hurt:
        model.remove(ontRes, RDF.type, OWL.Ontology);
      }
    }

   
   
    ///////////////////////////////////////////////////////
    // Update attributes in model:

    Map<String, Property> uriPropMap = MdHelper.getUriPropMap();
    for ( String uri : newValues.keySet() ) {
      String value = newValues.get(uri).trim();
      if ( value.length() > 0 ) {
        Property prop = uriPropMap.get(uri);
        if ( prop == null ) {
          log.info("No property found for uri='" +uri+ "'");
          continue;
        }
View Full Code Here


      //
      for ( AttrGroup attrGroup : metadataBaseInfo.getAttrGroups() ) {
        for ( AttrDef attrDef : attrGroup.getAttrDefs() ) {
         
          // get value of MMI property:
          Property mmiProp = uriPropMap.get(attrDef.getUri());
          String prefixedMmi = MdHelper.prefixedName(mmiProp);
          String value = JenaUtil2.getValue(ontRes, mmiProp);
         
          // DC equivalent, which is obtained if necessary
          Property dcProp = null;
         
          if (value == null) {
            // try a DC equivalent to use:
            dcProp = MdHelper.getEquivalentDcProperty(mmiProp);
            if ( dcProp != null ) {
              value = JenaUtil2.getValue(ontRes, dcProp);
            }
          }
         
          if ( value != null ) {
           
            // get value:
            if ( log.isDebugEnabled() ) {
              log.debug("Assigning: " +attrDef.getUri()+ " = " + value);
            }
            originalValues.put(attrDef.getUri(), value);
           
            // Special case: Omv.acronym/OmvMmi.shortNameUri 
            if ( Omv.acronym.getURI().equals(attrDef.getUri()) ) {
              // add also the value of OmvMmi.shortNameUri:
              String shortNameValue = JenaUtil2.getValue(ontRes, OmvMmi.shortNameUri);
              if ( log.isDebugEnabled() ) {
                log.debug("Also assigning " +OmvMmi.shortNameUri.getURI()+ " = " +shortNameValue);
              }
              originalValues.put(OmvMmi.shortNameUri.getURI(), shortNameValue);
            }
           
           

            // add detail:
            if ( dcProp != null ) {
              String prefixedDc = MdHelper.prefixedName(dcProp);
              _addDetail(moreDetails, prefixedMmi, "not present", "Will use " +prefixedDc);
            }
            else {
              _addDetail(moreDetails, prefixedMmi, "present", " ");
            }
          }
          else {
            if ( attrDef.isRequired() && ! attrDef.isInternal() ) {
              if ( dcProp != null ) {
                String prefixedDc = MdHelper.prefixedName(dcProp);
                _addDetail(moreDetails, prefixedMmi, "not present", "and " +prefixedDc+ " not present either");
             
              else {
                _addDetail(moreDetails, prefixedMmi, "not present", " not equivalent DC");
              }
            }
          }
        }
      }
    }
    else {
      //
      // No ontology resource. Check required attributes to report in the details:
      //
      for ( AttrGroup attrGroup : metadataBaseInfo.getAttrGroups() ) {
        for ( AttrDef attrDef : attrGroup.getAttrDefs() ) {
          if ( attrDef.isRequired() && ! attrDef.isInternal() ) {
            Property mmiProp = uriPropMap.get(attrDef.getUri());
            String prefixedMmi = MdHelper.prefixedName(mmiProp);
            _addDetail(moreDetails, prefixedMmi, "not present", "required");
          }
        }
      }
View Full Code Here

    if ( iter.hasNext() ) {
      Ontology ont = (Ontology) iter.next();
      for ( String uri : values.keySet() ) {
        String value = values.get(uri);
        if ( value.trim().length() > 0 ) {
          Property prop = ResourceFactory.createProperty(uri);
          if ( doSet  &&  ont.getPropertyValue(prop) != null ) {
            ont.removeAll(prop);
          }
          ont.addProperty(prop, value.trim());
        }
View Full Code Here

      while ( it.hasNext() ) {
        Triple triple = it.next();
        String objLab = triple.getObjectLabel();
       
        Resource sbj = ResourceFactory.createResource(triple.getSubjectLabel());
        Property prd = ResourceFactory.createProperty(triple.getPredicateLabel());
        RDFNode obj;
     
      if ( triple.getObject() instanceof ResourceNode ) {
        obj = ResourceFactory.createResource(objLab);
      }
View Full Code Here

 
  public static Property addDatatypeProperty(Model model,
      Resource conceptSubClass,
      String propUri, String propLabel
  ) {
    Property prop = model.createProperty(propUri);
   
    Statement stmt;
   
    stmt = model.createStatement(prop, RDF.type, OWL.DatatypeProperty);
    model.add(stmt);
View Full Code Here

        while (iter.hasNext()) {
          com.hp.hpl.jena.rdf.model.Statement sta = iter.nextStatement();
         
          out.printf("<tr>%n");
             
          Property prd = sta.getPredicate();
          String prdUri = prd.getURI();
          if ( prdUri != null ) {
            out.printf("<td><a href=\"%s\">%s</a></td>", prdUri, prdUri);
          }
          else {
            out.printf("<td>%s</td>", prd.toString());
          }
         
          RDFNode obj = sta.getObject();
          String objUri = null;
          if ( obj instanceof Resource ) {
View Full Code Here

    List<String> fields = new ArrayList<String>();

    Set<Statement> stmts = _info.getDataTypePropertyInstantiations(instance);
    if ( stmts != null ) {
      for (Statement stmt : stmts ) {
        Property prd = stmt.getPredicate();
        Literal obj = (Literal) stmt.getObject();
       
        String prdLabel = _info.getLabel(prd);
        String objLabel = obj.getString();
       
View Full Code Here

        continue;
      }
     
      Resource sbj = stmt.getSubject();
      String sbjName = sbj.getURI();
      Property prd = stmt.getPredicate();
      RDFNode obj = stmt.getObject();
      String objName = obj.isResource() ?
          ((Resource) obj).getURI() : ((Literal) obj).getString();
         
      if ( obj.isAnon() ) {
        String id = ((Resource) obj).getId().getLabelString();
        objName = id;
        Map<String, Restriction> restrictions = _info.getRestrictions();
        Restriction restr = restrictions.get(id);
        if ( restr != null ) {
          objName = _getRestrictionDescription(restr);
        }
      }
      else if ( objName == null ) {
        objName = "?";
      }
     
      String label = _info.getLabel(prd);
     
      if ( _generatedClasses.contains(sbj)
      ||   _generatedInstances.contains(sbj) )
      {
        String urlStr = includeUrls ? " URL=\"" +prd.getURI()+ "\"" : "";
       
        pw.println("  \"" +sbjName+ "\"  ->  \"" + objName+ "\"  [ label=\"" +label+ "\" " +
            urlStr+ " ]");
      }
    }
View Full Code Here

    StmtIterator iter = ontModel.listStatements();
    while ( iter.hasNext() ) {
      final Statement stmt = iter.nextStatement();
     
      final Resource sbj = stmt.getSubject();
      final Property prd = stmt.getPredicate();
      final RDFNode obj = stmt.getObject();
     
      if ( sbj.isAnon() ) {
        continue;
      }
     
      if ( prd.getNameSpace().equals(RDFS.getURI()) ) {
//        System.out.println(" ///////**** " +prd);

        if ( RDFS.label.equals(prd) ) {
          Literal objLit = (Literal) obj;
          _rdfsLabels.put(sbj, objLit.getLexicalForm());
View Full Code Here

   
    OntModel model = retrieveOntology();

    // add a new statement for termUri in the model:
    Resource termResource = ResourceFactory.createResource(termUri);
    Property description = ResourceFactory.createProperty(descriptionUri);
    String descriptionString = "Generated description " +System.currentTimeMillis();
    Literal descriptionObject = ResourceFactory.createPlainLiteral(descriptionString);
    Statement statement = ResourceFactory.createStatement(termResource, description, descriptionObject);
    model.add(statement);
    System.out.println("New statement: " +statement);
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Property

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.