Package edu.isi.karma.kr2rml.template

Examples of edu.isi.karma.kr2rml.template.TemplateTermSet


      subjectTermsToPaths.put(term, path);
    }
  }
  protected TemplateTermSet generateSubjectMapTemplateForBlankNode(SubjectMap subjectMap,
      List<String> columnsCovered) {
    TemplateTermSet subjectTerms = new TemplateTermSet();
    subjectTerms.addTemplateTermToSet(new StringTemplateTerm(Uris.BLANK_NODE_PREFIX));
    subjectTerms.addTemplateTermToSet(new StringTemplateTerm(kr2rmlMapping.getAuxInfo().getBlankNodesUriPrefixMap().get(subjectMap.getId()).replaceAll(":", "_")));
    for(String columnCovered : columnsCovered)
    {
      ColumnTemplateTerm term = new ColumnTemplateTerm(columnCovered);
      subjectTerms.addTemplateTermToSet(term);
    }
    return subjectTerms;
  }
View Full Code Here


 
  private boolean addPredicate(PredicateObjectMap pom,
      KR2RMLColumnNameFormatter columnNameFormatter, RepFactory factory,
      URI pomUri) throws RepositoryException {
    // Add the predicate
    TemplateTermSet predTermSet = pom.getPredicate().getTemplate();
    if (predTermSet.isSingleUriString()) {
      URI predValUri = f.createURI(predTermSet
          .getR2rmlTemplateString(factory, columnNameFormatter));
     
      // Skip the class instance special meta property
      if (predValUri.stringValue().equals(Uris.CLASS_INSTANCE_LINK_URI))
        return false;
     
      con.add(pomUri, repoURIs.get(Uris.RR_PREDICATE_URI), predValUri);
    } else {
      Value predValLiteratl = f.createLiteral(predTermSet.
          getR2rmlTemplateString(factory, columnNameFormatter));
      con.add(pomUri, repoURIs.get(Uris.RR_PREDICATE_URI), predValLiteratl);
    }
    return true;
  }
View Full Code Here

      con.add(rfUri, repoURIs.get(Uris.KM_IS_PART_OF_MAPPING_URI), mappingRes);
      con.add(mappingRes, repoURIs.get(Uris.KM_HAS_OBJECT_MAP_URI), rfUri);
      // Add the RefObjectMap as the object map of current POMap
      con.add(pomUri, repoURIs.get(Uris.RR_OBJECTMAP_URI), rfUri);
    } else {
      TemplateTermSet objTermSet = pom.getObject().getTemplate();
      TemplateTermSet rdfLiteralTypeTermSet = pom.getObject().getRdfLiteralType();
       
      if (objTermSet.isSingleColumnTerm()) {
        BNode cnBnode = f.createBNode();
        Value cnVal = f.createLiteral(objTermSet.
            getColumnNameR2RMLRepresentation(factory, columnNameFormatter));
       
        con.add(cnBnode, repoURIs.get(Uris.RR_COLUMN_URI), cnVal);
        con.add(cnBnode, RDF.TYPE, repoURIs.get(Uris.RR_OBJECTMAP_CLASS_URI));
        if (rdfLiteralTypeTermSet != null && rdfLiteralTypeTermSet.isSingleUriString()) {
          String rdfLiteralTypeString = rdfLiteralTypeTermSet.
              getR2rmlTemplateString(factory);
          if(!rdfLiteralTypeString.isEmpty())
          {
            Value cnRdfLiteralType = f.createLiteral(rdfLiteralTypeString);
            con.add(cnBnode, repoURIs.get(Uris.RR_DATATYPE_URI), cnRdfLiteralType);
          }

        }
        con.add(cnBnode, repoURIs.get(Uris.KM_IS_PART_OF_MAPPING_URI), mappingRes);
        con.add(mappingRes, repoURIs.get(Uris.KM_HAS_OBJECT_MAP_URI), cnBnode);
       
        // Add the link b/w blank node and object map
        con.add(pomUri, repoURIs.get(Uris.RR_OBJECTMAP_URI), cnBnode);
      }
      else if(!objTermSet.isEmpty())
      {
        BNode cnBnode = f.createBNode();
        // Print out the template for anything that isn't a blank node
        boolean isUri = false;
       
        for (TemplateTerm term:objTermSet.getAllTerms()) {
          if (term instanceof StringTemplateTerm) {
            if(((StringTemplateTerm)term).hasFullUri())
              isUri = true;
          }
        }
           
        String value = objTermSet
            .getR2rmlTemplateString(factory, columnNameFormatter);
        Value templVal;
        if(isUri) {
          try {
            templVal = f.createURI(value);
          }catch(IllegalArgumentException e) {
            String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(
                Property.baseURI);
            templVal = f.createURI(baseURI + value);
          }
        } else {
          templVal = f.createLiteral(value);
        }
        con.add(cnBnode, repoURIs.get(Uris.RR_CONSTANT), templVal);
        if (rdfLiteralTypeTermSet != null && rdfLiteralTypeTermSet.isSingleUriString()) {
          String rdfLiteralTypeString = rdfLiteralTypeTermSet.
              getR2rmlTemplateString(factory);
          if(!rdfLiteralTypeString.isEmpty())
          {
            Value cnRdfLiteralType = f.createLiteral(rdfLiteralTypeString);
            con.add(cnBnode, repoURIs.get(Uris.RR_DATATYPE_URI), cnRdfLiteralType);
View Full Code Here

  private boolean isBlankNode;
  private boolean isSteinerTreeRootNode;
 
  public SubjectMap(String id) {
    super(id);
    this.template = new TemplateTermSet();
    this.rdfsTypes = new ArrayList<TemplateTermSet>();
    this.isBlankNode = false;
    this.setAsSteinerTreeRootNode(false);
  }
View Full Code Here

    }
  }

  private TemplateTermSet expandColumnTemplateTermForPyTransforms(
      String hNodeId, ColumnTemplateTerm cnTerm) {
    TemplateTermSet tts = null;
    String pythonCommand = worksheet.getMetadataContainer().getColumnMetadata().getColumnPython(hNodeId);
    List<PythonTransformationToken> tokens = PythonTransformationAsURITokenizer.tokenize(pythonCommand);
    PythonTransformationAsURIValidator validator = new PythonTransformationAsURIValidator();
    if(validator.validate(tokens))
    {
      tts = this.transformationToTemplateTermSet.translate(tokens, hNodeId);
    }
    else
    {
      tts = new TemplateTermSet();
      tts.addTemplateTermToSet(cnTerm);
    }
    return tts;
  }
View Full Code Here

         
          else if(target instanceof LiteralNode) {
            LiteralNode lnode = (LiteralNode) target;
           
            //Create the object
            TemplateTermSet termSet = new TemplateTermSet();
            StringTemplateTerm literalTerm = new StringTemplateTerm(lnode.getValue(), lnode.isUri());
            termSet.addTemplateTermToSet(literalTerm);
           
            StringTemplateTerm rdfLiteralTypeTerm = new StringTemplateTerm(lnode.getLabel().getUri(), true);
            TemplateTermSet rdfLiteralTypeTermSet = new TemplateTermSet();
            rdfLiteralTypeTermSet.addTemplateTermToSet(rdfLiteralTypeTerm);
           
            ObjectMap objMap = new ObjectMap(target.getId(), termSet, rdfLiteralTypeTermSet);
            poMap.setObject(objMap);
           
            // Create the predicate
            Predicate pred = new Predicate(olink.getId());
            pred.getTemplate().addTemplateTermToSet(
                  new StringTemplateTerm(olink.getLabel().getUri(), true));
           
            poMap.setPredicate(pred);
            if (generateInverse)
              addInversePropertyIfExists(subjMap, poMap, olink, subjTrMap);
           
          }
         
          // Create a data property map
          else if(target instanceof ColumnNode) {
            // Create the object map
            ColumnNode cnode = (ColumnNode) target;
            String hNodeId = cnode.getHNodeId();
            String columnName = translator.getColumnNameForHNodeId(hNodeId);
            ColumnTemplateTerm cnTerm = new ColumnTemplateTerm(columnName);
            TemplateTermSet termSet = expandColumnTemplateTermForPyTransforms(
                hNodeId, cnTerm);
           
            String rdfLiteralUri =   cnode.getRdfLiteralType() == null? "" : cnode.getRdfLiteralType().getUri();
            StringTemplateTerm rdfLiteralTypeTerm = new StringTemplateTerm(rdfLiteralUri, true);
            TemplateTermSet rdfLiteralTypeTermSet = new TemplateTermSet();
            rdfLiteralTypeTermSet.addTemplateTermToSet(rdfLiteralTypeTerm);

            ObjectMap objMap = new ObjectMap(hNodeId, termSet, rdfLiteralTypeTermSet);
            poMap.setObject(objMap);
           
            // Create the predicate
View Full Code Here

        PredicateObjectMap poMap = new PredicateObjectMap(PredicateObjectMap.getNewId(),subjTrMap);
       
        // Create the object map
        String columnName = translator.getColumnNameForHNodeId(hNodeId);
        ColumnTemplateTerm cnTerm = new ColumnTemplateTerm(columnName);
        TemplateTermSet termSet = new TemplateTermSet();
        termSet.addTemplateTermToSet(cnTerm);
        ObjectMap objMap = new ObjectMap(hNodeId, termSet, null);
        poMap.setObject(objMap);
       
        // Create the predicate
        Predicate pred = new Predicate(synType.getType().getUri() + "-synonym" +
View Full Code Here

TOP

Related Classes of edu.isi.karma.kr2rml.template.TemplateTermSet

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.