Package eu.scape_project.planning.model.policy

Examples of eu.scape_project.planning.model.policy.PreservationCase


        ResultSet pcResults = pcQe.execSelect();

        try {
            while ((pcResults != null) && (pcResults.hasNext())) {
                QuerySolution pcQs = pcResults.next();
                PreservationCase pc = new PreservationCase();
                pc.setName(pcQs.getLiteral("name").toString());
                pc.setUri(pcQs.getResource("preservationcase").getURI());
                pc.setContentSet(pcQs.getResource("contentset").getURI());
                preservationCases.add(pc);

                // determine user communities
                statement = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
                    + "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> "
                    + "PREFIX pc: <http://purl.org/DP/preservation-case#> "
                    + "SELECT ?usercommunity WHERE { "
                    + "<" + pc.getUri() + ">" + " pc:hasUserCommunity ?usercommunity } ";

                Query ucQuery = QueryFactory.create(statement, Syntax.syntaxARQ);

                QueryExecution ucQe = QueryExecutionFactory.create(ucQuery, model);
                ResultSet ucResults = ucQe.execSelect();

                try {
                    String ucs = "";
                    while ((ucResults != null) && ucResults.hasNext()) {
                        QuerySolution ucQs = ucResults.next();

                        ucs += "," + ucQs.getResource("usercommunity").getLocalName();
                    }
                    if (StringUtils.isNotEmpty(ucs)) {
                        pc.setUserCommunities(ucs.substring(1));
                    }
                } finally {
                    ucQe.close();
                }

                // query objectives
                statement = "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
                    + "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "
                    + "PREFIX pc: <http://purl.org/DP/preservation-case#> "
                    + "PREFIX skos: <http://www.w3.org/2004/02/skos/core#> "
                    + "PREFIX cp: <http://purl.org/DP/control-policy#> "
                    + "SELECT ?objective ?objective_label ?objectiveType ?measure ?modality ?value ?qualifier WHERE { "
                    + "<" + pc.getUri() + ">" + " pc:hasObjective ?objective . "
                    + "?objective rdf:type ?objectiveType . "
                    + "?objectiveType rdfs:subClassOf cp:Objective . "
                    + "?objective skos:prefLabel ?objective_label . "
                    + "?objective cp:measure ?measure . "
                    + "?objective cp:value ?value . " + "OPTIONAL {?objective cp:qualifier ?qualifier} . "
                    + "OPTIONAL {?objective cp:modality ?modality} }";

                Query query = QueryFactory.create(statement, Syntax.syntaxARQ);
                QueryExecution qe = QueryExecutionFactory.create(query, model);
                ResultSet results = qe.execSelect();

                try {

                    while ((results != null) && (results.hasNext())) {
                        QuerySolution qs = results.next();
                        ControlPolicy cp = new ControlPolicy();

                        String controlPolicyUri = qs.getResource("objective").getURI();
                        String controlPolicyName = qs.getLiteral("objective_label").toString();
                        String measureUri = qs.getResource("measure").toString();
                        String modality = qs.getResource("modality").getLocalName();
                        String value = qs.getLiteral("value").getString();
                        Resource qualifier = qs.getResource("qualifier");

                        Measure m = criteriaManager.getMeasure(measureUri);

                        cp.setUri(controlPolicyUri);
                        cp.setName(controlPolicyName);
                        cp.setValue(value);
                        cp.setMeasure(m);

                        if (qualifier != null) {
                            cp.setQualifier(ControlPolicy.Qualifier.valueOf(qualifier.getLocalName()));
                        } else {
                            cp.setQualifier(ControlPolicy.Qualifier.EQ);
                        }
                        cp.setModality(ControlPolicy.Modality.valueOf(modality));

                        pc.getControlPolicies().add(cp);
                    }
                } finally {
                    qe.close();
                }
            }
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.policy.PreservationCase

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.