Ejemplo n.º 1
0
    @Override
    protected Serializable processMethod() throws AsyncException {
      StmtIterator mappings =
          m.listStatements(
              getHandler("mappings"), null, LocationMappingVocab.mapping, (RDFNode) null);

      for (; mappings.hasNext(); ) {
        Statement s = mappings.nextStatement();
        Resource mapping = s.getResource();

        if (mapping.hasProperty(getHandler(""), LocationMappingVocab.name)) {
          try {
            String name =
                mapping
                    .getRequiredProperty(getHandler("name"), LocationMappingVocab.name)
                    .getString();
            String altName =
                mapping
                    .getRequiredProperty(getHandler("altName"), LocationMappingVocab.altName)
                    .getString();
            addAltEntry(name, altName);
            log.log(Level.ALL, "Mapping: " + name + " => " + altName);
            //		                    log.debug("Mapping: "+name+" => "+altName) ;
          } catch (JenaException ex) {
            log.log(Level.ALL, "Error processing name mapping: " + ex.getMessage());
            //		                    log.warn("Error processing name mapping: "+ex.getMessage()) ;
            return null;
          }
        }

        if (mapping.hasProperty(getHandler(""), LocationMappingVocab.prefix)) {
          try {
            String prefix =
                mapping
                    .getRequiredProperty(getHandler("prefix"), LocationMappingVocab.prefix)
                    .getString();
            String altPrefix =
                mapping
                    .getRequiredProperty(getHandler("altPrefix"), LocationMappingVocab.altPrefix)
                    .getString();
            addAltPrefix(prefix, altPrefix);
            log.log(Level.ALL, "Prefix mapping: " + prefix + " => " + altPrefix);
            //		                    log.debug("Prefix mapping: "+prefix+" => "+altPrefix) ;
          } catch (JenaException ex) {
            log.log(Level.ALL, "Error processing prefix mapping: " + ex.getMessage());
            //		                    log.warn("Error processing prefix mapping: "+ex.getMessage()) ;
            return null;
          }
        }
      }

      return null;
    }
Ejemplo n.º 2
0
 /**
  * Helper. Adds to the target model a translation of the given RDF list with each element replaced
  * according to the map.
  */
 private Resource mapList(Model target, Resource list, Map<Resource, Resource> map) {
   if (list.equals(RDF.nil)) {
     return RDF.nil;
   } else {
     Resource head = (Resource) list.getRequiredProperty(RDF.first).getObject();
     Resource rest = (Resource) list.getRequiredProperty(RDF.rest).getObject();
     Resource mapElt = target.createResource();
     Resource mapHead = map.get(head);
     if (mapHead == null) mapHead = head;
     mapElt.addProperty(RDF.first, mapHead);
     mapElt.addProperty(RDF.rest, mapList(target, rest, map));
     return mapElt;
   }
 }
Ejemplo n.º 3
0
  void runTestAsk(Query query, QueryExecution qe) throws Exception {
    boolean result = qe.execAsk();
    if (results != null) {
      if (results.isBoolean()) {
        boolean b = results.getBooleanResult();
        assertEquals("ASK test results do not match", b, result);
      } else {
        Model resultsAsModel = results.getModel();
        StmtIterator sIter =
            results.getModel().listStatements(null, RDF.type, ResultSetGraphVocab.ResultSet);
        if (!sIter.hasNext()) throw new QueryTestException("Can't find the ASK result");
        Statement s = sIter.nextStatement();
        if (sIter.hasNext()) throw new QueryTestException("Too many result sets in ASK result");
        Resource r = s.getSubject();
        Property p = resultsAsModel.createProperty(ResultSetGraphVocab.getURI() + "boolean");

        boolean x = r.getRequiredProperty(p).getBoolean();
        if (x != result) assertEquals("ASK test results do not match", x, result);
      }
    }
    return;
  }