Package at.tuwien.minireef

Examples of at.tuwien.minireef.ResultSet


        if (sourceFormat != null && !"".equals(sourceFormat.getPuid())) {
            puid = sourceFormat.getPuid();
        }
        params.put("PUID", puid);
       
        ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params);
        ArrayList<PreservationActionDefinition> result = new ArrayList<PreservationActionDefinition>();

        if (resultSet == null) {
            // this should not happen if MiniREEF is properly configured
            log.error("querying miniREEF/P2 knowledge base failed for statement: " + statement);
            return result;
        }
       
        PreservationActionDefinition def;
        for (int i = 0 ; i < resultSet.size(); i++) {
            def = new PreservationActionDefinition();
            def.setShortname("Convert using " + resultSet.getRow(i).get(0)+" "+resultSet.getRow(i).get(1));
            def.setTargetFormat(resultSet.getRow(i).get(2)+" "+resultSet.getRow(i).get(3));
            def.setInfo("by "+resultSet.getRow(i).get(4));
            def.setActionIdentifier("P2");
            def.setExecutable(false);
//            if (service.getTargetFormat() != null) {
//               def.setTargetFormat(service.getTargetFormat().getDefaultExtension());
//               def.setTargetFormatInfo(service.getTargetFormat());
View Full Code Here


           
            String result = null;
           
            // add additional params if necessary
            // ...
            ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params);
            listener.updateStatus("MiniREEF is attempting to evaluate "+propertyURI);

            if (resultSet == null) {
                // this should not happen, if MiniREEF is properly configured
                listener.updateStatus("querying MiniREEF/P2 knowledge base failed for statement: " + statement);
                // skip this leaf
                continue;
            }
           
            // evaluation was successful!
            if (propertyURI.startsWith(FORMAT_NUMBEROFTOOLS)){
                // _measure_ is the number of tools found
                result = "" + resultSet.size();
                value.parse(result);
                // add names of tools as comment
                value.setComment(toCommaSeparated(resultSet.getColResults("swname")) +
                       "; - according to miniREEF/P2 knowledge base");
                listener.updateStatus("MiniREEF evaluated "+propertyURI);
            } else if ((FORMAT_LICENSE_OPEN.equals(propertyURI))||
                       (FORMAT_LICENSE_IPR_PROTECTED.equals(propertyURI))||
                       (FORMAT_LICENSE_PROPRIETARY.equals(propertyURI))) {
                if (resultSet.size() > 0) {
                    // we query for rights information in general, this way we can clarify the deduced result
                    // e.g. open = false, comment: "Format is encumbered by IPR"
                    boolean open = false;
                    boolean ipr = false;
                    boolean proprietary = false;
                    String comment = "";
                    for (int i=0; i < resultSet.size(); i++) {
                        // collect all results, even though there should be only one, the user can take care of it
                        List<String> vals = resultSet.getRow(i);
                        comment = comment + vals.get(0)+"\n";
                        String type = vals.get(1);
                        if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_IPR_PROTECTED.equals(type)) {
                            ipr = true;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_PROPRIETARY.equals(type)) {
                            proprietary = true;
                        }else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_OPEN.equals(type)) {
                            open = true;
                        }
                    }
                    if (resultSet.size() > 1) {
                        comment = comment + "more than one right category applies to this format, check for reason of this conflict.\n";
                    }
                    boolean boolResult = false;
                    if (FORMAT_LICENSE_OPEN.equals(propertyURI)) {
                        boolResult = open;
                    } else if (FORMAT_LICENSE_IPR_PROTECTED.equals(propertyURI)) {
                        boolResult = ipr;
                    } else if (FORMAT_LICENSE_PROPRIETARY.equals(propertyURI)) {
                        boolResult = proprietary;
                    }
                    value = scale.createValue();
                    ((BooleanValue)value).bool(boolResult);
                    value.setComment(comment + "according to MiniREEF/P2 knowledge base");
                    listener.updateStatus("MiniREEF evaluated "+propertyURI);
                }
                listener.updateStatus("P2 does not contain enough information to evaluate "+propertyURI+" for this format.");
            } else if ((FORMAT_COMPLEXITY.equals(propertyURI)) ||
                       (FORMAT_DISCLOSURE.equals(propertyURI)) ||
                       (FORMAT_UBIQUITY.equals(propertyURI))   ||
                       (FORMAT_DOCUMENTATION_QUALITY.equals(propertyURI))||
                       (FORMAT_STABILITY.equals(propertyURI))||
                       (FORMAT_LICENSE.equals(propertyURI)))  {
                if (resultSet.size()>0) {
                    String text = resultSet.getRow(0).get(0);
                    if (text.trim().length() > 0) {
                        value = scale.createValue();
                        value.parse(text);
                        value.setComment("according to miniREEF/P2 knowledge base");
                    }
View Full Code Here

public class ResultSetTest {
   
    @Test
    public void testContent() throws InvalidArgumentException {
        ResultSet result = new ResultSet();
        result.setColumnNames(Arrays.asList("count", "a", "b"));
        result.addRow(Arrays.asList("1", "a1", "b1"));
        result.addRow(Arrays.asList("2", "a2", "b2"));
        result.addRow(Arrays.asList("3", "a3", "b3"));
       
        List<String> colResults = result.getColResults("count");
        assert (colResults.size() == 3);
       
        for (int i = 0; i < colResults.size(); i ++) {
            assert ((""+i).equals(colResults.get(i)));
        }
        colResults = result.getColResults("b");
        assert (colResults.size() == 3);
       
        for (int i = 0; i < colResults.size(); i ++) {
            assert (("b"+i).equals(colResults.get(i)));
        }
View Full Code Here

        if (sourceFormat != null && !"".equals(sourceFormat.getPuid())) {
            puid = sourceFormat.getPuid();
        }
        params.put("PUID", puid);

        ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params);
        ArrayList<IServiceInfo> result = new ArrayList<IServiceInfo>();

        if (resultSet == null) {
            // this should not happen if MiniREEF is properly configured
            log.error("querying miniREEF/P2 knowledge base failed for statement: " + statement);
            return result;
        }

        for (int i = 0; i < resultSet.size(); i++) {
            ActionInfo def = new ActionInfo();
            def.setShortname("Convert using " + resultSet.getRow(i).get(0) + " " + resultSet.getRow(i).get(1));
            def.setTargetFormat(resultSet.getRow(i).get(2) + " " + resultSet.getRow(i).get(3));
            def.setInfo("by " + resultSet.getRow(i).get(4));
            def.setActionIdentifier("P2");
            def.setExecutable(false);
            // if (service.getTargetFormat() != null) {
            // def.setTargetFormat(service.getTargetFormat().getDefaultExtension());
            // def.setTargetFormatInfo(service.getTargetFormat());
View Full Code Here

            String result = null;

            // add additional params if necessary
            // ...
            ResultSet resultSet = MiniREEFResolver.getInstance().resolve(statement, params);
            listener.updateStatus("MiniREEF is attempting to evaluate " + measureId);

            if (resultSet == null) {
                // this should not happen, if MiniREEF is properly configured
                listener.updateStatus("querying MiniREEF/P2 knowledge base failed for statement: " + statement);
                // skip this leaf
                continue;
            }

            // evaluation was successful!
            if (measureId.startsWith(MeasureConstants.NUMBER_OF_TOOLS)) {
                scale = new PositiveIntegerScale();
                value = scale.createValue();

                // _measure_ is the number of tools found
                result = "" + resultSet.size();
                value.parse(result);
                // add names of tools as comment
                value.setComment(toCommaSeparated(resultSet.getColResults("swname"))
                    + "; - according to miniREEF/P2 knowledge base");
                listener.updateStatus("MiniREEF evaluated " + measureId);
            } else if (MeasureConstants.FORMAT_IPR_PROTECTION.equals(measureId)) {
                scale = new OrdinalScale();

                if (resultSet.size() > 0) {
                    // e.g. open = false, comment: "Format is encumbered by IPR"
                    String comment = "";
                    String valueStr = "";
                    for (int i = 0; i < resultSet.size(); i++) {
                        List<String> vals = resultSet.getRow(i);
                        comment = comment + vals.get(0) + "\n";
                        String type = vals.get(1);
                        if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_IPR_PROTECTED.equals(type)) {
                            valueStr = "ipr_protected";
                            comment = comment + valueStr;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_PROPRIETARY.equals(type)) {
                            valueStr = "proprietary";
                            comment = comment + valueStr;
                        } else if (P2_RESOURCE_FORMAT_LICENSE_RIGHTS_OPEN.equals(type)) {
                            valueStr = "open";
                            comment = comment + valueStr;
                        }
                    }
                    if (resultSet.size() > 1) {
                        comment = comment
                            + ": more than one right category applies to this format, check for reason of this conflict.\n";
                    }
                    value = scale.createValue();
                    value.parse(valueStr);
                    value.setComment(comment + ": according to MiniREEF/P2 knowledge base");
                    listener.updateStatus("MiniREEF evaluated " + measureId);
                }
                listener.updateStatus("P2 does not contain enough information to evaluate " + measureId
                    + " for this format.");
            } else if ((MeasureConstants.FORMAT_COMPLEXITY.equals(measureId))) {
                // || (MeasureConstants.FORMAT_DISCLOSURE.equals(measureId))
                // FIXME: the results from p2 have to be matched to the defined
                // measures
                // || (MeasureConstants.FORMAT_UBIQUITY.equals(measureId))
                // ||
                // (MeasureConstants.FORMAT_DOCUMENTATION_QUALITY.equals(measureId))
                // || (MeasureConstants.FORMAT_STABILITY.equals(measureId))
                // || (MeasureConstants.FORMAT_LICENSE.equals(measureId))) {

                scale = new OrdinalScale();

                if (resultSet.size() > 0) {
                    String text = resultSet.getRow(0).get(0);
                    if (text.trim().length() > 0) {
                        value = scale.createValue();
                        value.parse(text);
                        value.setComment("according to miniREEF/P2 knowledge base");
                    }
View Full Code Here

TOP

Related Classes of at.tuwien.minireef.ResultSet

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.