當前位置: 首頁>>代碼示例>>Java>>正文


Java Resource類代碼示例

本文整理匯總了Java中org.apache.jena.rdf.model.Resource的典型用法代碼示例。如果您正苦於以下問題:Java Resource類的具體用法?Java Resource怎麽用?Java Resource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Resource類屬於org.apache.jena.rdf.model包,在下文中一共展示了Resource類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConcept

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
public Concept createConcept(URI uri, Label prefLabel, URI[] classURIs, UUID uuid) throws ModelException {
	Resource conceptURIResource = resourceFromURI(model, uri);

	if (resourceInUse(conceptURIResource)) throw new ModelException("Attempting to create concept with URI - '%s'. This URI is already in use.", uri.toString());
	
	if ((classURIs == null) || (classURIs.length == 0)) {
		conceptURIResource.addProperty(RDF.type, SKOS.Concept);
	} else {
		for (URI classURI: classURIs) {
			conceptURIResource.addProperty(RDF.type, resourceFromURI(model, classURI));
		}
	}
	
	conceptURIResource.addLiteral(SEM.guid, (uuid == null ? Utils.generateGuid(uri.toString()) : uuid.toString()));
		
	URI labelURI = getLabelURI(model, conceptURIResource, SKOS.prefLabel, prefLabel);
	Resource labelURIResource = resourceFromURI(model, labelURI);
	model.add(conceptURIResource, SKOSXL.prefLabel, labelURIResource);
	model.add(labelURIResource, SKOSXL.literalForm, getAsLiteral(model, prefLabel));
	model.add(labelURIResource, RDF.type, SKOSXL.Label);
	return new Concept(model, conceptURIResource);
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:23,代碼來源:SemaphoreModel.java

示例2: resourcesEqual

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
public static boolean resourcesEqual(Resource res1, Resource res2) {

      // seems to be either true,true,false -or- false,true,true:
      //System.out.println("res1: "+res1.isAnon());
      //System.out.println("res1: "+res1.isResource());
      //System.out.println("res1: "+res1.isURIResource());

      if (res1.isAnon() && res2.isAnon()) {
        if (res1.getId().equals(res2.getId()))
          return true;
      }
      else {
        if (res1.isAnon()) {
        }
        else {
          if (res2.isAnon()) {
          }
          else {
            if (res1.getURI().equals(res2.getURI()))
              return true;
          }
        }
      }
      return false;
    }
 
開發者ID:tag42git,項目名稱:CsvTupler,代碼行數:26,代碼來源:NodeFactory.java

示例3: testLocalDiff

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Test
public void testLocalDiff() throws Exception {
  Model firstModel = ModelFactory.createDefaultModel();
  firstModel.read("Playpen2.ttl", "TTL");

  Model secondModel = ModelFactory.createDefaultModel();
  secondModel.add(firstModel);
  Resource res1 = secondModel.createResource(resIri1);
  res1.addProperty(RDF.type, SKOS.Concept);

  client.setCurrentModel(firstModel);
  client.setPendingModel(secondModel);
  assertEquals(firstModel, client.getCurrentModel());
  assertEquals(secondModel, client.getPendingModel());

  RDFDifference diff = client.getBatchDiff();

  assertTrue(diff.getInLeftOnly().size() == 0);
  assertTrue(diff.getInRightOnly().size() == 1);

  assertFalse(diff.getInLeftOnly().containsResource(res1));
  assertFalse(diff.getInLeftOnly().contains(res1, RDF.type, SKOS.Concept));

  assertTrue(diff.getInRightOnly().containsResource(res1));
  assertTrue(diff.getInRightOnly().contains(res1, RDF.type, SKOS.Concept));
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:27,代碼來源:OEBatchClientTests.java

示例4: fillTrie

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Override
protected void fillTrie(Logger logger, Trie<Resource> trie, Corpus corpus) throws IOException, ModuleException {
	Model model = createModel(logger);
	Property typeProp = model.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
	Property[] labelPropertyProps = getProperties(model, labelURIs);
	int nEntries = 0;
	for (String resourceTypeURI : resourceTypeURIs) {
		Property resourceType = model.getProperty(model.expandPrefix(resourceTypeURI));
		for (Resource res : Iterators.loop(model.listSubjectsWithProperty(typeProp , resourceType))) {
			if (res.isAnon()) {
				continue;
			}
			for (Property prop : labelPropertyProps) {
				for (RDFNode node : Iterators.loop(model.listObjectsOfProperty(res, prop))) {
					String label = getNodeValue(node);
					trie.addEntry(label, res);
					nEntries++;
				}
			}
		}
	}
	logger.info("Entries: " + nEntries);
}
 
開發者ID:Bibliome,項目名稱:alvisnlp,代碼行數:24,代碼來源:RDFProjector.java

示例5: getJenaModel

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
private Model getJenaModel(@NonNull org.eclipse.rdf4j.model.Model model) {
  Model jenaModel = ModelFactory.createDefaultModel();
  java.util.Iterator<org.eclipse.rdf4j.model.Statement> iterator = model.iterator();

  while (iterator.hasNext()) {
    org.eclipse.rdf4j.model.Statement rdf4jStatement = iterator.next();

    // create resource / subject
    Resource resource = rdf4jResourceToJenaResource(jenaModel, rdf4jStatement.getSubject());
    // create property / predicate
    Property property =
        rdf4jPropertyToJenaProperty(jenaModel, (SimpleIRI) rdf4jStatement.getPredicate());
    // create rdfnode / object
    RDFNode node = rdf4jValueToJenaRdfNode(jenaModel, rdf4jStatement.getObject());

    Statement statement = ResourceFactory.createStatement(resource, property, node);
    jenaModel.add(statement);
  }
  return jenaModel;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:21,代碼來源:ShaclValidator.java

示例6: addTriple

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Override
public void addTriple(CrawleableUri uri, Triple triple) {
    String uriString = uri.getUri().toString();
    if (rdfData.containsKey(uriString)) {
        Model model = rdfData.get(uriString);
        Resource s;
        Node n = triple.getSubject();
        if (n.isBlank()) {
            s = model.createResource(new AnonId(triple.getSubject().getBlankNodeId()));
        } else {
            s = model.createResource(triple.getSubject().getURI());
        }
        Property p = model.createProperty(triple.getPredicate().getURI());
        if (triple.getObject().isURI()) {
            model.add(s, p, model.createResource(triple.getObject().getURI()));
        } else if (triple.getObject().isBlank()) {
            model.add(s, p, model.createResource(new AnonId(triple.getObject().getBlankNodeId())));
        } else {
            model.add(s, p, triple.getObject().getLiteralValue().toString());
        }
    } else {
        LOGGER.error("Called to add a triple to the URI \"" + uriString + "\" which has never been opened.");
        healthyness = false;
    }
}
 
開發者ID:dice-group,項目名稱:Squirrel,代碼行數:26,代碼來源:InMemorySink.java

示例7: makeSampleModel

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
private static Model makeSampleModel() {
	String BASE = "http://example/";
	
	Model model = ModelFactory.createDefaultModel();
	model.setNsPrefix("", BASE);
	Resource r1 = model.createResource(BASE + "r1");
	Resource r2 = model.createResource(BASE + "r2");
	Property p1 = model.createProperty(BASE + "p");
	Property p2 = model.createProperty(BASE + "p2");
	RDFNode v1 = model.createTypedLiteral("1", XSDDatatype.XSDinteger);
	RDFNode v2 = model.createTypedLiteral("2", XSDDatatype.XSDinteger);

	r1.addProperty(p1, v1).addProperty(p1, v2);
	r1.addProperty(p2, v1).addProperty(p2, v2);
	r2.addProperty(p1, v1).addProperty(p1, v2);

	return model;
}
 
開發者ID:iotoasis,項目名稱:SDA,代碼行數:19,代碼來源:SDADatasetAccessor.java

示例8: from

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Override
public List<Statement> from() {
	Type type = new TypeToken<List<SurveyInfoDTO>>() {
	}.getType();
	Gson gson = new Gson();
	List<SurveyInfoDTO> surveyList = gson.fromJson(content, type);

	Iterator<SurveyInfoDTO> it = surveyList.iterator();
	
	while (it.hasNext()) {
		Resource _surveury = model.createResource(baseuri+"/campus/Survey_"+UUID.randomUUID());
		List<Statement> _slist = getStatementList( it.next(), _surveury);
		slist.addAll(_slist);
	}
	
	return slist;
}
 
開發者ID:iotoasis,項目名稱:SDA,代碼行數:18,代碼來源:SurveyServiceMapper.java

示例9: generateSubjects

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
/**
 * Returns a list of synonymous expressions as subject for the given
 * resource.
 * 
 * @param resource
 *            the resource
 * @param resourceType
 *            the type of the resource
 * @param resourceGender
 *            the gender of the resource
 * @return list of synonymous expressions
 */
public List<NPPhraseSpec> generateSubjects(Resource resource, OWLClass resourceType, Gender resourceGender) {
	List<NPPhraseSpec> result = new ArrayList<NPPhraseSpec>();
	// the textual representation of the resource itself
	result.add(nlg.getNPPhrase(resource.getURI(), false, false));
	// the class, e.g. 'this book'
	NPPhraseSpec np = nlg.getNPPhrase(resourceType.toStringID(), false);
	np.addPreModifier("This");
	result.add(np);
	// the pronoun depending on the gender of the resource
	if (resourceGender.equals(Gender.MALE)) {
		result.add(nlg.nlgFactory.createNounPhrase("he"));
	} else if (resourceGender.equals(Gender.FEMALE)) {
		result.add(nlg.nlgFactory.createNounPhrase("she"));
	} else {
		result.add(nlg.nlgFactory.createNounPhrase("it"));
	}
	return result;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:31,代碼來源:Verbalizer.java

示例10: from

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Override
public List<Statement> from() {
	Type type = new TypeToken<List<SurveyInfoDTO>>() {
	}.getType();
	Gson gson = new Gson();
	List<SurveyInfoDTO> surveyList = gson.fromJson(content, type);

	Iterator<SurveyInfoDTO> it = surveyList.iterator();
	
	while (it.hasNext()) {
		Resource _surveury = model.createResource(baseuri+"/Survey_"+UUID.randomUUID());
		List<Statement> _slist = getStatementList( it.next(), _surveury);
		slist.addAll(_slist);
	}
	
	return slist;
}
 
開發者ID:iotoasis,項目名稱:SDA,代碼行數:18,代碼來源:SurveyServiceMapper.java

示例11: modelToSystemMetaData

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
public List<SystemMetaData> modelToSystemMetaData(Model model) throws Exception {
    List<SystemMetaData> results = new ArrayList<>();

    // find all system subjects
    List<Resource> systems = getResources(model, HOBBIT.SystemInstance);
    for (Resource system : systems) {
        SystemMetaData result = new SystemMetaData();
        // set URI
        result.systemUri = system.getURI();
        // find name
        result.systemName = getName(model, system);
        // find description
        result.systemDescription = getDescription(model, system);
        // find image name
        result.system_image_name = getImage(model, system);
        // find APIs
        result.implementedApis = getAPIs(model, system, false);
        // find used images
        result.usedImages = getUsedImages(model, system);
        // append to results
        results.add(result);
    }

    return results;
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:26,代碼來源:ImageManagerImpl.java

示例12: getBenchmarkUri

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
protected String getBenchmarkUri(Model model) {
    // find benchmark subject
    Resource benchmark = null;
    ResIterator subjects = model.listSubjectsWithProperty(RDF.type, HOBBIT.Benchmark);
    if (subjects.hasNext()) {
        benchmark = subjects.next();
    }

    // check if benchmark was actually found
    if (benchmark == null) {
        return null;
    }

    // set URI
    return benchmark.getURI();
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:17,代碼來源:ImageManagerImpl.java

示例13: modelToBenchmarkMetaData

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
protected static ExtBenchmarkMetaData modelToBenchmarkMetaData(Model model, Resource benchmark) throws Exception {
    ExtBenchmarkMetaData result = new ExtBenchmarkMetaData();

    // set URI
    result.benchmarkUri = benchmark.getURI();
    // find name
    result.benchmarkName = getName(model, benchmark);
    // find description
    result.benchmarkDescription = getDescription(model, benchmark);
    // find APIs
    result.implementedApis = getAPIs(model, benchmark, true);

    result.model = model;

    return result;
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:17,代碼來源:FileBasedImageManager.java

示例14: getBenchmarkUri

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
protected static String getBenchmarkUri(Model model) {
    // find benchmark subject
    Resource benchmark = null;
    ResIterator subjects = model.listSubjectsWithProperty(RDF.type, HOBBIT.Benchmark);
    if (subjects.hasNext()) {
        benchmark = subjects.next();
    }

    // check if benchmark was actually found
    if (benchmark == null) {
        return null;
    }

    // set URI
    return benchmark.getURI();
}
 
開發者ID:hobbit-project,項目名稱:platform,代碼行數:17,代碼來源:FileBasedImageManager.java

示例15: inferClasses

import org.apache.jena.rdf.model.Resource; //導入依賴的package包/類
@Override
public Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology) {

    final OntModel model = resolveImports(ont(ontology));
    model.add(parse(resource));

    final Individual individual = model.getIndividual(uri.toString());

    if (individual != null) {
        return individual
                .listRDFTypes(false)
                .filterKeep(Resource::isURIResource)
                .mapWith(Resource::getURI)
                .mapWith(URI::create)
                .toSet();
    } else {
        LOG.info("<{}> does not make any statements about itself, " +
                "so we can't infer anything about it nor bind extensions to it", uri);
        return Collections.emptySet();
    }

}
 
開發者ID:fcrepo4-labs,項目名稱:fcrepo-api-x,代碼行數:23,代碼來源:JenaOntologyService.java


注:本文中的org.apache.jena.rdf.model.Resource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。