Package eu.planets_project.tb.api.data.util

Examples of eu.planets_project.tb.api.data.util.DataHandler


                + ", type=" + type + "]";
        }
    }
   
    private String lookupFileName( String dobUri ) {
        DataHandler dh = DataHandlerImpl.findDataHandler();
        DigitalObjectRefBean dorb;
        try {
            dorb = dh.get(dobUri);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return "Missing file!";
        }
        return dorb.getName();
View Full Code Here


  /**
     *
     */
    private void init( String file ) {
        // Populate using the results:
        DataHandler dh = DataHandlerImpl.findDataHandler();
        // Set up the DO name, etc
        setDigitalObject(file);
        DigitalObjectRefBean bean;
        try {
            bean = dh.get(file);
            setDownloadURL(bean.getDownloadUri().toString());
            setDigitalObjectName(DataHandlerImpl.createShortDOName(bean.getName()));
        } catch (Exception e) {
            setDownloadURL("");
            setDigitalObjectName(DataHandlerImpl.createShortDOName(file));
View Full Code Here

         */
        public String getDigitalObjectResult() {
            String summary = "";
            String tbDigoURI = this.getDobResultReference();
            if( tbDigoURI != null ) {
                DataHandler dh = new DataHandlerImpl();
                DigitalObjectRefBean dobr;
                try {
                    dobr = dh.get(tbDigoURI);
                } catch (FileNotFoundException e) {
                    log.error("Could not find file. "+e);
                    return "";
                }
                if( dobr == null ) return "";
View Full Code Here

         * e.g. https://localhost:8443/testbed/reader/download.jsp?fid=file%253A%252FD%253A%252FImplementation%252Fifr_server%252Fplanets-ftp%252Fusa_bundesstaaten_png.png
         * @return
         */
        private String getDigitalObjectDownloadURL(Object tbDigoURI) {
            if( tbDigoURI != null ) {
                DataHandler dh = new DataHandlerImpl();
                try {
                    DigitalObjectRefBean dobr = dh.get((String)tbDigoURI);
                    return dobr.getDownloadUri().toString();
                } catch ( Exception e ) {
                    log.error("Failed to generate download URL. " + e);
                    return "";
                }
View Full Code Here

                  //iterate over all input files
                  for(String localFileRef : this.inputData.values()) {
                      // Clean up the localFileRef, so that the TB can cope with it's data store being moved.
                      //store a set of file BMGoals for every record item
                      DataHandler dh = new DataHandlerImpl();
                      DigitalObjectRefBean dorb = dh.get(localFileRef);
                      if( dorb != null ) {
                          URI inputFileURI = dorb.getDownloadUri();
                          Collection<BenchmarkGoal> colFileBMGoals = exp.getExperimentEvaluation().getEvaluatedFileBenchmarkGoals(inputFileURI);
                          if(colFileBMGoals==null)
                              throw new Exception("Exception while setting file benchmarks for record: "+inputFileURI);
View Full Code Here

    }
   
   
    private Collection<Map<String,String>> helperGetDataNamesAndURIS(String expStage){
      Collection<Map<String,String>> ret = new Vector<Map<String,String>>();
      DataHandler dh = new DataHandlerImpl();
     
      //when we're calling this in design experiment -> fetch the input data refs
      if(expStage.equals("design experiment")){
        Map<String, String> localFileRefs = this.getExperimentInputData();
          for( String key : localFileRefs.keySet() ) {
              boolean found = false;
            try {
              Map<String,String> map = new HashMap<String,String>();
              //retrieve URI
                String fInput = localFileRefs.get(key);
                DigitalObjectRefBean dobr = dh.get(fInput);
                if( dobr != null ) {
                    URI uri = dobr.getDownloadUri();
                    map.put("uri", uri.toString()) ;
                    map.put("name", this.createShortDoName(dobr) );
                    map.put("inputID", key);
                    ret.add(map);
                    found = true;
                } else {
                    log.error("Digital Object "+key+" could not be found!");
                }
          } catch (FileNotFoundException e) {
            log.error(e.toString());
          }
          // Catch lost items...
          if( !found ) {
                    Map<String,String> map = new HashMap<String,String>();
                    String fInput = localFileRefs.get(key);
                    map.put("uri", fInput);
                    map.put("name", "ERROR: Digital Object Not Found: " + getLeafnameFromPath(fInput));
                    map.put("inputID", key);
                    ret.add(map);
          }
          }
      }
      //when we're calling this in evaluate experiment -> fetch the external eval data refs
      if(expStage.equals("evaluate expeirment") && this.getEvaluationExternalDigoRefs() != null ){
        for(String digoRef : this.getEvaluationExternalDigoRefs()){
          try {
          Map<String,String> map = new HashMap<String,String>();
          DigitalObjectRefBean dobr = dh.get(digoRef);
          if(dobr != null ) {
            URI uri = dobr.getDownloadUri();
            map.put("uri", uri.toString()) ;
            map.put("name", this.createShortDoName(dobr) );
            map.put("inputID", dobr.getDomUri()+"");
View Full Code Here

    public Collection<Map<String,Object>> getIOTableDataForGUI(){
      //Entry of inputComponent, outputComponent
      Collection<Map<String,Object>> ret = new Vector<Map<String,Object>>();
      Iterator<Entry<String,String>> itData = this.outputData.iterator();
     
      DataHandler dh = new DataHandlerImpl();
      while(itData.hasNext()){
        Entry<String,String> entry = itData.next();
        String input = entry.getKey();
        String output = entry.getValue();
       
        //mixing different objects within this map
        HashMap<String,Object> hm = new HashMap<String,Object>();
       //For the Input:
        try{
        //test: convert input to URI
                DigitalObjectRefBean dobr = dh.get(input);
          URI uriInput = dobr.getDownloadUri();
          //add "inputURI" and "inputName" into ret hashmap
          hm.put("input", uriInput.toString());
          hm.put("inputName", dobr.getName());
          hm.put("inputTypeURI", "URI");
         
        }
        catch(Exception e){
          //this input was not a file or fileRef not readable  - display as text
          hm.put("input", input);
          hm.put("inputName", null);
          hm.put("inputTypeURI", null);
        }
       
       //For the Output:
        try{
            //test: convert output to URI
                DigitalObjectRefBean dobr = dh.get(output);
            URI uriOutput = dobr.getDownloadUri();
            //add "outputURI" and "outputName" "outputType" into ret hashmap
          hm.put("output", uriOutput.toString());
          hm.put("outputName", dobr.getName());
          hm.put("outputTypeURI", "URI");
View Full Code Here

     */
    public void helperCreateRemoveFileElement(UIComponent panel, String fileRef, String key){
        log.info("Looking for fileRef: "+fileRef+" w/ key: "+key);
        try {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            DataHandler dh = new DataHandlerImpl();
            //file ref
            HtmlOutputText outputText = (HtmlOutputText) facesContext
                    .getApplication().createComponent(
                            HtmlOutputText.COMPONENT_TYPE);
            DigitalObjectRefBean dobr = dh.get(fileRef);
            outputText.setValue(" "+dobr.getName());
            outputText.setId("fileName" + key);
            //file name
            HtmlOutputLink link_src = (HtmlOutputLink) facesContext
                    .getApplication().createComponent(
View Full Code Here

     if(expBean.getExperiment().getExperimentExecutable().getBatchExecutionRecords().size()!=lTempFileDownloadLinkForWEEWFResults.size()){
       lTempFileDownloadLinkForWEEWFResults = new ArrayList<String>();
       for(BatchExecutionRecordImpl batchRec : expBean.getExperiment().getExperimentExecutable().getBatchExecutionRecords()){
        if((batchRec.getWorkflowExecutionLog()!=null)&&(batchRec.getWorkflowExecutionLog().getSerializedWorkflowResult()!=null)){
          //create a temp file for this.
          DataHandler dh = new DataHandlerImpl();
          try {
            //get a temporary file
            File f = dh.createTempFileInExternallyAccessableDir();
            Writer out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream(f), "UTF-8" ) );
            out.write(batchRec.getWorkflowExecutionLog().getSerializedWorkflowResult());
            out.close();
            lTempFileDownloadLinkForWEEWFResults.add(""+dh.getHttpFileRef(f));
          } catch (Exception e) {
            log.debug("Error getting getTempFileDownloadLinkForWEEWFResults "+e);
            return new ArrayList<String>();
          }
        }
View Full Code Here

       
        try {
            // FIXME, Some experiment types may take all DOBs into one workflow?  Emulation?
           
            // Set up the basics:
            DataHandler dh = new DataHandlerImpl();
            int total = job.getDigitalObjects().size();
            int i = 0;
           
           
            // Process each in turn:
            for( String filename : job.getDigitalObjects() ) {
                Calendar start = Calendar.getInstance();
                log.info("Running job: "+(i+1)+"/"+total);
                DigitalObject dob = dh.get(filename).getDigitalObject();
                WorkflowResult wfr = null;
               
                // Actually run the workflow:
                try {
                    wfr = this.executeWorkflowOn(job, dob);
View Full Code Here

TOP

Related Classes of eu.planets_project.tb.api.data.util.DataHandler

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.