Java 类com.hp.hpl.jena.rdf.model.Bag 实例源码

项目:xcurator    文件:Mapping.java   
public static Set<String> getAllTypes(Model model, String typePrefix) {
    Resource rootResource = model.createResource(typePrefix);

    com.hp.hpl.jena.rdf.model.Property classProperty = model.createProperty("http://dblab.cs.toronto.edu/project/xcurator/0.1#classes");
    Bag classBag = model.createBag("http://dblab.cs.toronto.edu/project/xcurator/0.1#classBag");
    model.add(rootResource, classProperty, classBag);

    Set<String> ret = new HashSet<String>();

    NodeIterator iterator = classBag.iterator();
    while (iterator.hasNext()) {
        Resource resource = (Resource) iterator.next();
        ret.add(resource.getURI());
    }

    return ret;
}
项目:quality    文件:ValidIFPUsage.java   
Model createProblemModel(Model m){
    Bag bag = m.createBag(Commons.generateURI().getURI());

    Resource problemURI = t.getProblemURI();

    if (!(m.contains(problemURI, RDF.type, DQMPROB.InverseFunctionalPropertyViolation))){
        m.add(problemURI, RDF.type, DQMPROB.InverseFunctionalPropertyViolation);
        m.add(problemURI, DQMPROB.violatedPredicate, Commons.asRDFNode(q.getPredicate()));
        m.add(problemURI, DQMPROB.violatedObject, Commons.asRDFNode(q.getObject()));

        bag = m.createBag();
        bag.add(t.getSubject());
        m.add(problemURI, DQMPROB.violatingSubjects, bag);
    }
    Resource bagURI = m.listObjectsOfProperty(problemURI, DQMPROB.violatingSubjects).next().asResource();
    bag = m.getBag(bagURI);
    m.remove(problemURI, DQMPROB.violatingSubjects, bag);

    bag.add(Commons.asRDFNode(q.getSubject()));
    m.add(problemURI, DQMPROB.violatingSubjects, bag);

    return m;
}
项目:giftgenie.io    文件:TestGet.java   
public void testGetBag()
{
    final String uri = "http://aldabaran.hpl.hp.com/rdf/test4/" + 150;
    model.createBag(uri);
    final Bag b = model.getBag(uri);
    Assert.assertEquals(uri, b.getURI());
    Assert.assertTrue(model.contains(b, RDF.type, RDF.Bag));
}
项目:quality    文件:DataCubePopulationCompleteness.java   
private void addToProblemReport(Resource codedProperty, Set<Resource> setCodedProperties){
    Resource uri = Commons.generateURI();
    problemModel.add(uri, RDF.type, DQMPROB.MissingPopulationCoverage);
    problemModel.add(uri, DQMPROB.forCodedProperty, codedProperty.asResource());

    Bag bag = problemModel.createBag(Commons.generateURI().getURI());
    for (Resource r : setCodedProperties){
        try{
            bag.add(r);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    this.problemModel.add(uri, DQMPROB.missingPopulationCoverageList, bag);
}
项目:sadlos2    文件:ConfigurationManagerForEditing.java   
public void updateConfiguration(ConfigurationItem newItem)
        throws ConfigurationException {
    if (getConfigModel() != null) {
        Resource type = getConfigModel().createResource(CATEGORY_KW);
        Property subcatprop = getConfigModel().createProperty(
                SUBCATEGORY_PROP); // we'll use this repeatedly
        String[] categoryHierarchy = newItem.getCategoryHierarchy();
        Resource lastCategory = null;
        List<NameValuePair> nvplist = newItem.getNameValuePairs();
        for (int i = 0; i < categoryHierarchy.length; i++) {
            Resource newCategory = getConfigModel().createResource(
                    CONFIG_NAMESPACE + categoryHierarchy[i], type);
            if (i > 0) {
                getConfigModel().add(lastCategory, subcatprop, newCategory);
            }
            lastCategory = newCategory;
        }
        if (lastCategory != null) {
            for (int i = 0; nvplist != null && i < nvplist.size(); i++) {
                NameValuePair nvp = nvplist.get(i);
                Property prop = getConfigModel().createProperty(
                        CONFIG_NAMESPACE + nvp.getName());
                Statement stmt = lastCategory.getProperty(prop);
                if (stmt != null) {
                    if (nvp.getConfigType().equals(ConfigurationType.Bag)) {
                        throw new ConfigurationException(
                                "Can't update a Bag");
                    } else if (nvp.getConfigType().equals(
                            ConfigurationType.Sequence)) {
                        throw new ConfigurationException(
                                "Can't update a Sequence");
                    } else {
                        Statement updateStmt = lastCategory
                                .getProperty(getConfigModel()
                                        .createProperty(
                                                CONFIG_NAMESPACE
                                                        + nvp.getName()));
                        updateStmt.changeObject(getConfigModel()
                                .createTypedLiteral(nvp.getValue()));
                    }
                } else {
                    getConfigModel().add(
                            lastCategory,
                            prop,
                            getConfigModel().createTypedLiteral(
                                    nvp.getValue()));
                }
            }
        }
        clearReasoner();
        setConfigChanged(true);
    }
}
项目:sadlos2    文件:ConfigurationManagerForEditing.java   
public void updateConfiguration(ConfigurationItem newItem)
        throws ConfigurationException {
    if (getConfigModel() != null) {
        Resource type = getConfigModel().createResource(CATEGORY_KW);
        Property subcatprop = getConfigModel().createProperty(
                SUBCATEGORY_PROP); // we'll use this repeatedly
        String[] categoryHierarchy = newItem.getCategoryHierarchy();
        Resource lastCategory = null;
        List<NameValuePair> nvplist = newItem.getNameValuePairs();
        for (int i = 0; i < categoryHierarchy.length; i++) {
            Resource newCategory = getConfigModel().createResource(
                    CONFIG_NAMESPACE + categoryHierarchy[i], type);
            if (i > 0) {
                getConfigModel().add(lastCategory, subcatprop, newCategory);
            }
            lastCategory = newCategory;
        }
        if (lastCategory != null) {
            for (int i = 0; nvplist != null && i < nvplist.size(); i++) {
                NameValuePair nvp = nvplist.get(i);
                Property prop = getConfigModel().createProperty(
                        CONFIG_NAMESPACE + nvp.getName());
                Statement stmt = lastCategory.getProperty(prop);
                if (stmt != null) {
                    if (nvp.getConfigType().equals(ConfigurationType.Bag)) {
                        throw new ConfigurationException(
                                "Can't update a Bag");
                    } else if (nvp.getConfigType().equals(
                            ConfigurationType.Sequence)) {
                        throw new ConfigurationException(
                                "Can't update a Sequence");
                    } else {
                        Statement updateStmt = lastCategory
                                .getProperty(getConfigModel()
                                        .createProperty(
                                                CONFIG_NAMESPACE
                                                        + nvp.getName()));
                        updateStmt.changeObject(getConfigModel()
                                .createTypedLiteral(nvp.getValue()));
                    }
                } else {
                    getConfigModel().add(
                            lastCategory,
                            prop,
                            getConfigModel().createTypedLiteral(
                                    nvp.getValue()));
                }
            }
        }
        clearReasoner();
        setConfigChanged(true);
    }
}
项目:oro-server    文件:PartialStatement.java   
@Override
public Bag getBag() {
    return baseStmt.getBag();
}
项目:quality    文件:PredicateClusteringIndexing.java   
public Model evaluationModel(Map<String,String> typesMap){
    Model m = ModelFactory.createDefaultModel();

    Resource thisEval = Commons.generateURI();
    Property _setP = m.createProperty("uri:minimumFractionObjectP"); //MIN_FRACTION_OBJ_P
    Property _approxD = m.createProperty("uri:approximateD"); //approxD
    Property _setResSize = m.createProperty("uri:reserviorSize"); // RESERVIOR SIZE
    Property _noTriples = m.createProperty("uri:numberOfTriples"); 
    Property _maximumM = m.createProperty("uri:maximumM");
    Property _assessedProperty = m.createProperty("uri:assessedProperty");
    Property _totalOutliers = m.createProperty("uri:totalOutliers");
    Property _simMeasureUsed = m.createProperty("uri:similarityMeasureUsed");
    Property _icMeasureUsed = m.createProperty("uri:icMeasureUsed");


    double mm = this.triples.size() * (1 - MIN_FRACTION_OBJ_P);

    m.add(m.createStatement(thisEval, _setP, m.createTypedLiteral(MIN_FRACTION_OBJ_P)));
    m.add(m.createStatement(thisEval, _approxD, m.createTypedLiteral(this.approxD)));
    m.add(m.createStatement(thisEval, _setResSize, m.createTypedLiteral(RESERVOIR_SIZE)));
    m.add(m.createStatement(thisEval, _noTriples, m.createTypedLiteral(this.triples.size())));
    m.add(m.createStatement(thisEval, _maximumM, m.createTypedLiteral(mm)));
    m.add(m.createStatement(thisEval, _assessedProperty, m.createResource(this.predicate)));
    m.add(m.createStatement(thisEval, _totalOutliers, m.createTypedLiteral(this.outliers.size())));
    m.add(m.createStatement(thisEval, _simMeasureUsed, m.createTypedLiteral(sim)));
    m.add(m.createStatement(thisEval, _icMeasureUsed, m.createTypedLiteral(ici)));

    Resource bag = Commons.generateURI();
    Bag b = m.createBag(bag.getURI());

    Property _hasSubject = m.createProperty("uri:subject");
    Property _hasSubjectType = m.createProperty("uri:subjectType");
    Property _hasObject = m.createProperty("uri:object");
    Property _hasObjectType = m.createProperty("uri:objectType");



    for (SerialisableTriple t : this.outliers){
        Resource outlier = Commons.generateURI();

        String subjType = typesMap.get(t.getTriple().getSubject().getURI());
        Resource resSubjType = null;
        if (subjType == null) resSubjType = OWL.Thing;
        else 
            resSubjType = (subjType.equals("")) ? OWL.Thing : m.createResource(subjType);

        String objType = typesMap.get(t.getTriple().getObject().getURI());
        Resource resObjType = null;
        if (objType == null) resObjType = OWL.Thing;
        else
            resObjType = (objType.equals("") ) ? OWL.Thing : m.createResource(objType);


        m.add(m.createStatement(outlier, _hasSubject, Commons.asRDFNode(t.getTriple().getSubject())));
        m.add(m.createStatement(outlier, _hasSubjectType,  resSubjType));
        m.add(m.createStatement(outlier, _hasObject, Commons.asRDFNode(t.getTriple().getObject())));
        m.add(m.createStatement(outlier, _hasObjectType, resObjType));

        b.add(outlier);
    }

    m.add(m.createStatement(thisEval, m.createProperty("urn:outliers"), b));

    return m;
}