Examples of PreservationActionDefinition


Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

                String targetFormat = targetFormats[i];
                /*
                 * Then get all the possible migration paths for each target format
                 * - each migration path corresponds to one service  
                 */
                PreservationActionDefinition action;
               
                MigrationPath[] paths = serviceRegistryService.getMigrationPaths(cribID, targetFormat);
                for (int j = 0; j < paths.length; j++) {
                    MigrationPath path = paths[j];
                    action = new PreservationActionDefinition();
                   
                    action.setShortname(getShortnameFromPath(path, shortnames));
                    String urls[] = path.getAccessPoints();
                    LinkedList<Parameter> params = new LinkedList<Parameter>();
                    for (int k = 0; k < urls.length; k++) {
                        Parameter param = new Parameter();
                        param.setName(""+k);
                        param.setValue(urls[k]);
                        params.add(param);
                    }
                    action.setParams(params);
                    action.setTargetFormat(targetFormats[i]);
                    if (urls.length > 0)
                        action.setUrl(urls[0].substring(0, urls[0].lastIndexOf("/")));
                    /*
                     * extract information about the conversions from urls
                     */
                    StringBuilder b = new StringBuilder();
                    b.append(getSourceFormatFromPath(urls[0]));
                    for(int uIdx = 0; uIdx < urls.length; uIdx++) {
                        b.append(">");
                        b.append(getTargetFormatFromPath(urls[uIdx]));
                    }
                    action.setInfo(b.toString());
                    /*
                     * mark this as a CRiB action
                     */
                    action.setActionIdentifier("CRiB");
                    /*
                     * no gif, bmp, text - conversions: they are of minor interest for dp
                     */
/*                String info = action.getInfo().toUpperCase();
                    if (!(info.contains("GIF") ||
View Full Code Here

Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

                }
               
                // get the output format the service is able to migrate to
                Format outputFormat = fr.getFormatForUri(path.getOutputFormat());

                PreservationActionDefinition pad = new PreservationActionDefinition();
               
                pad.setActionIdentifier("Planets-local");
                pad.setTargetFormat(outputFormat.getUri().toString());
                pad.setShortname(sd.getName() + " @ " + sd.getEndpoint().getHost());
                pad.setUrl(sd.getEndpoint().toString());
               
                String input;
               
                // if an extension is defined we take the first one from the list
                if (inputFormat.getExtensions().size() > 0) {
                    input = inputFormat.getExtensions().iterator().next();
                } else {
                    input = inputFormat.getUri().toString();
                }
               
                String output;
               
                // if an extension is defined we take the first one from the list               
                if (outputFormat.getExtensions().size() > 0) {
                    output = outputFormat.getExtensions().iterator().next();
                } else {
                    output = outputFormat.getUri().toString();
                }
               
                pad.setInfo(input+" > "+output);

               
               
                if (sd.getParameters() != null) {
                    String paramInfo = "";
                    // from the Planets registry we can have parameters and their possible values.
                    for (Parameter p : sd.getParameters()) {
                        paramInfo += (p.getName() + " = " + p.getValue() + "\n");
                    }
                   
                    pad.setParameterInfo(paramInfo);
                }
               
                services.add(pad);
            }
           
        }
       
        for (ServiceDescription sd : listViewers) {

            if (CreateView.class.getCanonicalName().equals(sd.getType())) {
                PreservationActionDefinition pad = new PreservationActionDefinition();
               
                pad.setActionIdentifier("Planets-Viewer-local");
                pad.setTargetFormat("");
                pad.setShortname(sd.getName() + " @ " + sd.getEndpoint().getHost());
                pad.setUrl(sd.getEndpoint().toString());
                pad.setEmulated(true);
               
                pad.setInfo(sd.getDescription());
               
                services.add(pad);
            }
        }
       
View Full Code Here

Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

                String targetFormat = targetFormats[i];
                /*
                 * Then get all the possible migration paths for each target format
                 * - each migration path corresponds to one service  
                 */
                PreservationActionDefinition action;
               
                MigrationPath[] paths = serviceRegistryService.findall_migrationPaths(cribID, targetFormat);
                for (int j = 0; j < paths.length; j++) {
                    MigrationPath path = paths[j];
                    action = new PreservationActionDefinition();
                   
                    action.setShortname(getShortnameFromPath(path, shortnames));
                    String urls[] = path.getAccessPoints();
                    LinkedList<Parameter> params = new LinkedList<Parameter>();
                    for (int k = 0; k < urls.length; k++) {
                        Parameter param = new Parameter();
                        param.setName("crib::location"+k);
                        param.setValue(urls[k]);
                        params.add(param);
                    }
                    action.setParams(params);
                    action.setTargetFormat(targetFormats[i]);
                    if (urls.length > 0)
                        action.setUrl(urls[0].substring(0, urls[0].lastIndexOf("/")));
                    /*
                     * extract information about the conversions from urls
                     */
                    StringBuilder b = new StringBuilder();
                    b.append(getSourceFormatFromPath(urls[0]));
                    for(int uIdx = 0; uIdx < urls.length; uIdx++) {
                        b.append(">");
                        b.append(getTargetFormatFromPath(urls[uIdx]));
                    }
                    action.setInfo(b.toString());
                    /*
                     * mark this as a CRiB action
                     */
                    action.setActionIdentifier("CRiB-local");
                    /*
                     * no gif, bmp, text - conversions: they are of minor interest for dp
                     */
/*                String info = action.getInfo().toUpperCase();
                    if (!(info.contains("GIF") ||
View Full Code Here

Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

            // 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());
//            }
//            def.setInfo(service.getDescription());
View Full Code Here

Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

    public List<PreservationActionDefinition> getAvailableActions(
            FormatInfo sourceFormat) throws PlatoServiceException {
        List<PreservationActionService> services = registry.findServices(sourceFormat, null);
        ArrayList<PreservationActionDefinition> result = new ArrayList<PreservationActionDefinition>();
        PreservationActionDefinition def;
        for (PreservationActionService service : services) {
            def = new PreservationActionDefinition();
            def.setShortname(service.getName());
            if (service.getTargetFormat() != null) {
               def.setTargetFormat(service.getTargetFormat().getDefaultExtension());
               def.setTargetFormatInfo(service.getTargetFormat());
            }
            def.setInfo(service.getDescription());
            def.setUrl(service.getUrl());
            def.setDescriptor(service.getDescriptor());
            if (service.isMigration())
               def.setActionIdentifier("MiniMEE-migration");
            else {
               def.setEmulated(true);
               def.setActionIdentifier("MiniMEE-emulation" );
               // TODO: refine setting type according to sourceFormat
               if ("avi".equals(sourceFormat.getDefaultExtension()) ||
                   "mpg".equals(sourceFormat.getDefaultExtension()) ||
                   "mpeg".equals(sourceFormat.getDefaultExtension())) {
                   def.setParamByName("filetype", "1");
               }
               else if ("jpg".equals(sourceFormat.getDefaultExtension()) ||
                   "gif".equals(sourceFormat.getDefaultExtension())||
                   "tif".equals(sourceFormat.getDefaultExtension())) {
                  def.setParamByName("filetype", "2");
               }
               else if ("pdf".equals(sourceFormat.getDefaultExtension()) ||
                        "sam".equals(sourceFormat.getDefaultExtension())) {
                  def.setParamByName("filetype", "3");
               }
            }
            result.add(def);
        }
       
View Full Code Here

Examples of eu.planets_project.pp.plato.model.PreservationActionDefinition

        }
        this.changed="T";
        // das sieht verd�chtig aus - pad wird auch geschrieben.
        // ABER die settings, die in pad eingetragen werden, brauchen wir nicht zum persistieren, sondern nur zum
        // ausf�hren der action - stehen ja in experiment.settings. daher ist es ok, dass wir die merged instance ver�ndern.
        PreservationActionDefinition pad = em.merge(a.getAction());
        pad.setExecute(a.getAction().isExecute());

        String settings = a.getExperiment().getSettings();
        pad.setParamByName("settings", settings);

        StringBuffer runDescription = new StringBuffer();

        if (action instanceof IMigrationAction) {
            DigitalObject migrationResultObject;
View Full Code Here

Examples of eu.scape_project.planning.model.PreservationActionDefinition

*/
public class MiniMeeMigrationService implements IMigrationAction {

    @Override
    public MigrationResult migrate(Alternative alternative, DigitalObject digitalObject) throws PlatoException {
        PreservationActionDefinition action = alternative.getAction();

        MigrationService service = new MigrationService();
        long start = System.nanoTime();
        String settings = "";
        if (action.isExecute()) {
            settings = action.getParamByName("settings");
        }
        MigrationResult result = service.migrate(digitalObject.getData().getData(), action.getUrl(), settings);
        setResultName(result, digitalObject);

        long duration = (System.nanoTime() - start) / (1000000);
        service.addExperience(result.getFeedbackKey(), action.getUrl(), new Measurement("roundtripTimeMS", new Double(
            duration)));
        return result;
    }
View Full Code Here

Examples of eu.scape_project.planning.model.PreservationActionDefinition

            facesMessages.addError("Could not retrieve workflow description from myExeriment.");
            return;
        }

        try {
            PreservationActionDefinition actionDefinition = new PreservationActionDefinition();
            actionDefinition.setActionIdentifier(serviceInfo.getServiceIdentifier());
            actionDefinition.setShortname(serviceInfo.getShortname());
            actionDefinition.setDescriptor(serviceInfo.getDescriptor());
            actionDefinition.setUrl(serviceInfo.getUrl());
            actionDefinition.setInfo(serviceInfo.getInfo());

            for (Port p : wf.getInputPorts()) {
                if (p.isParameterPort()) {
                    actionDefinition.getParams().add(new Parameter(p.getName(), ""));
                }
            }

            String uniqueName = plan.getAlternativesDefinition().createUniqueName(actionDefinition.getShortname());
            Alternative a = Alternative.createAlternative(uniqueName, actionDefinition);
            defineAlternatives.addAlternative(a);
        } catch (PlanningException e) {
            facesMessages.addError("Could not create an alternative from the service you selected.");
        }
View Full Code Here

Examples of eu.scape_project.planning.model.PreservationActionDefinition

        return result.isSuccessful();
    }

    @Override
    public MigrationResult migrate(Alternative alternative, DigitalObject digitalObject) throws PlatoException {
        PreservationActionDefinition action = alternative.getAction();

        SSHTavernaExecutor tavernaExecutor = new SSHTavernaExecutor();
        tavernaExecutor.init();

        MigrationResult result = new MigrationResult();

        HashMap<String, Object> inputData = new HashMap<String, Object>();

        WorkflowDescription workflowDescription = MyExperimentRESTClient.getWorkflow(action.getDescriptor());
        workflowDescription.readMetadata();
        if (!workflowDescription.getProfile().equals("http://purl.org/DP/components#MigrationAction")) {
            result.setSuccessful(false);
            result.setReport("The workflow " + action.getUrl() + " is no MigrationAction.");
            return result;
        }

        List<Port> inputPorts = workflowDescription.getInputPorts();

        for (Port p : inputPorts) {
            if (ComponentConstants.VALUE_SOURCE_OBJECT.equals(p.getValue())) {
                inputData.put(p.getName(),
                    tavernaExecutor.new ByteArraySourceFile(FileUtils.makeFilename(digitalObject.getFullname()),
                        digitalObject.getData().getData()));
            } else if (ComponentConstants.VALUE_PARAMETER.equals(p.getValue()) || p.getValue() == null) {
                String value = action.getParamByName(p.getName());
                if (value == null) {
                    value = "";
                }
                inputData.put(p.getName(), value);
            } else {
                result.setSuccessful(false);
                result.setReport("The workflow " + action.getUrl() + " has unsupported port " + p.getName()
                    + " that accepts " + p.getValue());
                return result;
            }
        }
        tavernaExecutor.setInputData(inputData);

        // Workflow
        tavernaExecutor.setWorkflow(action.getUrl());

        // Output ports to receive
        List<Port> outputPorts = workflowDescription.getOutputPorts();
        Set<String> outputPortNames = new HashSet<String>(outputPorts.size());
        String targetPathPort = null;
        for (Port p : outputPorts) {
            outputPortNames.add(p.getName());

            if (ComponentConstants.VALUE_TARGET_OBJECT.equals(p.getValue())) {
                targetPathPort = p.getName();
            }
        }
        tavernaExecutor.setOutputPorts(outputPortNames);

        // Output files
        if (targetPathPort == null) {
            result.setSuccessful(false);
            result.setReport("The workflow " + action.getUrl() + " has not target port.");
            return result;
        }
        HashMap<String, SSHInMemoryTempFile> requestedFiles = new HashMap<String, SSHInMemoryTempFile>(1);
        SSHInMemoryTempFile tempFile = new SSHInMemoryTempFile();
        requestedFiles.put(targetPathPort, tempFile);
        tavernaExecutor.setOutputFiles(requestedFiles);

        // Execute
        try {
            tavernaExecutor.execute();
        } catch (IOException e) {
            result.setSuccessful(false);
            result.setReport("Error connecting to execution server");
            log.error("Error connecting to execution server", e);
            return result;
        } catch (TavernaExecutorException e) {
            result.setSuccessful(false);
            result.setReport("Error executing taverna workflow");
            log.error("Error executing taverna workflow", e);
            return result;
        }

        result.setSuccessful(true);
        result.setReport(tavernaExecutor.getOutputDoc());

        Map<String, ?> outputFiles = tavernaExecutor.getOutputFiles();

        DigitalObject u = new DigitalObject();
        for (Entry<String, ?> entry : outputFiles.entrySet()) {
            SSHInMemoryTempFile resultFile = (SSHInMemoryTempFile) entry.getValue();
            u.getData().setData(resultFile.getData());
            u.setFullname(action.getShortname() + " - " + digitalObject.getFullname());
        }
        FormatInfo tFormat = new FormatInfo();
        result.setTargetFormat(tFormat);
        result.setMigratedObject(u);
View Full Code Here

Examples of eu.scape_project.planning.model.PreservationActionDefinition

        // Add ports
        generator.addSourcePort();
        generator.addTargetPort();

        // Migration action
        PreservationActionDefinition action = alternative.getAction();
        if (action != null) {
            try {
                WorkflowDescription wf = MyExperimentRESTClient.getWorkflow(action.getDescriptor());
                HashMap<String, String> parameters = new HashMap<String, String>();
                for (Parameter p : action.getParams()) {
                    parameters.put(p.getName(), p.getValue());
                }
                wf.readMetadata();
                String workflowContent = MyExperimentRESTClient.getWorkflowContent(wf);
                generator.setMigrationComponent(wf, workflowContent, parameters);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.