Package eu.planets_project.tb.api.model

Examples of eu.planets_project.tb.api.model.BasicProperties


        if( exp.getCurrentPhase() != null )
            log.debug("Experiment Current Phase Stage is " + exp.getCurrentPhase().getState());

        this.exp = exp;
      ExperimentSetup expsetup = exp.getExperimentSetup();
      BasicProperties props = expsetup.getBasicProperties();
      this.id = exp.getEntityID();
      this.ename =(props.getExperimentName());
      this.escope=(props.getScope());
      this.econsiderations=(props.getConsiderations());
      this.econtactaddress=(props.getContactAddress());
      this.econtactemail=(props.getContactMail());
      this.econtacttel=(props.getContactTel());
      this.econtactname=(props.getContactName());
       
        // references
        this.exid=props.getExternalReferenceID();
       
        List<String[]> lit = props.getAllLiteratureReferences();
        if (lit != null && !lit.isEmpty()) {
            this.litrefdesc = new ArrayList<String>(lit.size());
            this.litrefuri = new ArrayList<String>(lit.size());
            this.litreftitle = new ArrayList<String>(lit.size());
            this.litrefauthor = new ArrayList<String>(lit.size());
            for( int i = 0; i < lit.size(); i++ ) {
            this.litrefdesc.add(i, lit.get(i)[0]);
            this.litrefuri.add(i,lit.get(i)[1]);
            this.litreftitle.add(i,lit.get(i)[2]);
            this.litrefauthor.add(i,lit.get(i)[3]);
            }
        }      
       
        List<Long> refs = props.getExperimentReferences();
        if (refs != null && !refs.isEmpty()) {
            this.eref = new ArrayList<String>(refs.size());
            for( int i = 0; i < refs.size(); i++ )
                this.eref.add(i, ""+refs.get(i) );
        }       
        List<String> involvedUsers = props.getInvolvedUserIds();
        String partpnts = " ";
        for(int i=0;i<involvedUsers.size();i++) {
            partpnts +=involvedUsers.get(i);
            if( i < involvedUsers.size()-1 ) partpnts += ", ";
        }
       

        this.eparticipants = partpnts;
       
        String Test = props.getExternalReferenceID();
       
        this.exid=(Test);
       

        this.efocus=(props.getFocus());

      this.epurpose=(props.getPurpose());
      this.esummary=(props.getSummary());
      this.formality = props.isExperimentFormal();     
     
        //get already added TestbedServiceTemplate data
        log.debug("fill expBean: executable = "+exp.getExperimentExecutable());
        if(exp.getExperimentExecutable()!=null){
          ExperimentExecutable executable = exp.getExperimentExecutable();
          this.selSerTemplate = executable.getServiceTemplate();
          if( selSerTemplate != null )
              this.sSelSerTemplateID = selSerTemplate.getUUID();
          this.sSelSerOperationName = executable.getSelectedServiceOperationName();
          this.bOperationSelectionCompleted = true;
          helperLoadInputData(executable.getInputData());
          if(executable.isExecutionSuccess()){
            //uses the executable to get the data
              this.outputData = exp.getExperimentExecutable().getOutputDataEntries();
          }
        }
    
        //fill the file benchmarks
        log.info("Looking for BMGs... ");
        try {
          if (exp.getCurrentPhase() instanceof ExperimentEvaluation) {
              if (this.inputData != null) {

                  //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);

                          for(BenchmarkGoal bmg : colFileBMGoals){
                              log.info("Found fileBMG: " + bmg.getName());
                              log.info("Found fileBMG.id: " + bmg.getID());
                              //now crate the bmb out of the bmg
                              BenchmarkBean bmb = new BenchmarkBean(bmg);
                              bmb.setSourceValue(bmg.getSourceValue());
                              bmb.setTargetValue(bmg.getTargetValue());
                              bmb.setEvaluationValue(bmg.getEvaluationValue());
                              bmb.setWeight(String.valueOf(bmg.getWeight()));
                              bmb.setSelected(true);
                              if((bmb.getSourceValue()==null)||(bmb.getSourceValue().equals("")))
                                  bmb.setSrcError(true);
                              if((bmb.getTargetValue()==null)||(bmb.getTargetValue().equals("")))
                                  bmb.setTarError(true);             

                              //now add the file bmbs for this experimentbean
                              fileBenchmarks.put(inputFileURI+bmb.getID(), bmb);
                          }
                      }
            }
          }
          }
         
          //fill the experiment overall benchmarks
          Collection<BenchmarkGoal> lbmbs;
          if (exp.getCurrentPhase() instanceof ExperimentEvaluation){
            //get the data from the evaluation phase
            lbmbs = exp.getExperimentEvaluation().getEvaluatedExperimentBenchmarkGoals();
                log.info("Found eval #BMGs = " + lbmbs.size());
                log.info("Found pre-eval #BMGs = " + exp.getExperimentSetup().getAllAddedBenchmarkGoals().size());
                // if none, get the data from the setup phase
                if( lbmbs.size() == 0 )
                    lbmbs = exp.getExperimentSetup().getAllAddedBenchmarkGoals();
          }
          else{
            //get the data from the setup phase
            lbmbs = exp.getExperimentSetup().getAllAddedBenchmarkGoals();
                log.info("Found pre-eval #BMGs = " + lbmbs.size());
          }    
        for(BenchmarkGoal bmg : lbmbs){
                log.info("Found BMG: " + bmg.getName());
                log.info("Found BMG.id: " + bmg.getID());
            BenchmarkBean bmb = new BenchmarkBean(bmg);
            bmb.setSourceValue(bmg.getSourceValue());
            bmb.setTargetValue(bmg.getTargetValue());
            bmb.setEvaluationValue(bmg.getEvaluationValue());
            bmb.setWeight(String.valueOf(bmg.getWeight()));
            bmb.setSelected(true);
            experimentBenchmarks.put(bmg.getID(), bmb);
          }
        }catch (Exception e) {
          log.error("Exception during attempt to create ExperimentBean for: "+e.toString());
          if( log.isDebugEnabled() ) e.printStackTrace();
        }
     
       
      String intensity = Integer.toString(exp.getExperimentSetup().getExperimentResources().getIntensity());
      if (intensity != null && intensity != "-1")
        this.intensity = intensity;
      // determine current Stage
      ExperimentPhase currPhaseObj = exp.getCurrentPhase();
      if (currPhaseObj != null) {
        String currPhase = currPhaseObj.getPhaseName();
        if (currPhase.equals(ExperimentPhase.PHASENAME_EXPERIMENTSETUP)) {
          this.currStage = exp.getExperimentSetup().getSubStage();
        } else if (currPhase.equals(ExperimentPhase.PHASENAME_EXPERIMENTAPPROVAL)) {
          this.currStage = ExperimentBean.PHASE_EXPERIMENTAPPROVAL;
        } else if (currPhase.equals(ExperimentPhase.PHASENAME_EXPERIMENTEXECUTION)) {
          this.currStage = ExperimentBean.PHASE_EXPERIMENTEXECUTION;
            } else if (currPhase.equals(ExperimentPhase.PHASENAME_EXPERIMENTEVALUATION)) {
                this.currStage = ExperimentBean.PHASE_EXPERIMENTEVALUATION;
            } else if (currPhase.equals(ExperimentPhase.PHASENAME_EXPERIMENTFINALIZED)) {
                this.currStage = ExperimentBean.PHASE_EXPERIMENTFINALIZED;               
            }
      }
      if(currStage>ExperimentBean.PHASE_EXPERIMENTSETUP_3) {
          approved=true;
      } else {
          approved=false;
      }
       
        this.dtype = props.getDigiTypes();
       
        // Set the report up:
        this.ereportTitle = exp.getExperimentEvaluation().getExperimentReport().getHeader();
        this.ereportBody = exp.getExperimentEvaluation().getExperimentReport().getBodyText();
        this.evaluationData = exp.getExperimentEvaluation().getExternalEvaluationDocuments();
View Full Code Here


        ExperimentBean expBean = (ExperimentBean)JSFUtil.getManagedObject("ExperimentBean");
        log.info("ExpBean: "+expBean.getEname()+" : "+expBean.getEsummary());
       
        // Get the Experiment description objects
        Experiment exp = expBean.getExperiment();
        BasicProperties props = exp.getExperimentSetup().getBasicProperties();
        log.info("Setting the experimental properties, "+props.getExperimentName()+" : "+props.getSummary());
        // If the experiment already existed, check for valid name changes:
        try {
            props.setExperimentName(expBean.getEname());
        } catch (InvalidInputException e1) {
            e1.printStackTrace();
        }
       
        //set the experiment information
        props.setSummary(expBean.getEsummary());
        props.setConsiderations(expBean.getEconsiderations());
        props.setPurpose(expBean.getEpurpose());
        props.setFocus(expBean.getEfocus());
        props.setScope(expBean.getEscope());
        props.setContact(expBean.getEcontactname(),expBean.getEcontactemail(),expBean.getEcontacttel(),expBean.getEcontactaddress());      
        props.setExperimentFormal(expBean.getFormality());
        log.info("Set the experimental properties, "+props.getExperimentName()+" : "+props.getSummary());

        String partpnts = expBean.getEparticipants();
        String[] partpntlist = partpnts.split(",");
        for(int i=0;i<partpntlist.length;i++){
            partpntlist[i] = partpntlist[i].trim();
            if( partpntlist[i] != "" ) {
                props.addInvolvedUser(partpntlist[i]);
            }
        }
        props.setExternalReferenceID(expBean.getExid());
               
        ArrayList<String> litRefDesc = expBean.getLitRefDesc();
        ArrayList<String> litRefURI = expBean.getLitRefURI();    
        ArrayList<String> litRefTitle = expBean.getLitRefTitle();   
        ArrayList<String> litRefAuthor = expBean.getLitRefAuthor();
        if (litRefDesc != null && !litRefDesc.equals("")) {
            for( int i = 0; i < litRefDesc.size(); i++ ) {
                if( ! "".equals(litRefDesc.get(i).trim()) &&
                        ! "".equals(litRefURI.get(i).trim()) )//author etc. can be empty
                    props.addLiteratureReference( litRefDesc.get(i).trim(),
                            litRefURI.get(i).trim(), litRefTitle.get(i).trim(), litRefAuthor.get(i).trim() );
            }
        }
        List<Long> refs = new ArrayList<Long>();
        if (expBean.getEref() != null && !expBean.getEref().equals("")) {
            for( int i = 0; i < expBean.getEref().size(); i++)
                refs.add(Long.parseLong( (expBean.getEref().get(i)) ));
        }
        props.setExperimentReferences(refs);
       
        /*
        props.setDigiTypes(expBean.getDtype());
       
        log.debug("Checking the experiment type.");
View Full Code Here

        ExperimentImpl.resetToEditingStage(exp);
       
        // Make the current user the owner:
        UserBean user = (UserBean)JSFUtil.getManagedObject("UserBean");
        if( user != null ) {
            BasicProperties props = exp.getExperimentSetup().getBasicProperties();
            props.setExperimenter(user.getUserid());
            props.setContact(user.getFullname(), user.getEmail(), user.getTelephone(), user.getAddress());
        }

        // Place new experiment bean into session:
        ExperimentBean newExpBean = ExperimentInspector.putExperimentIntoRequestExperimentBean(exp);
        newExpBean.setUserData(user);
View Full Code Here

  protected void setUp(){

  }
 
  public void testConsiderations(){
    BasicProperties props = new BasicPropertiesImpl();
    String sConsiderations = "Consideration1";
    props.setConsiderations(sConsiderations);
   
    assertEquals(sConsiderations, props.getConsiderations());
  }
View Full Code Here

  }
 
 
  public void testContact(){
    //Test: setContact
    BasicProperties props = new BasicPropertiesImpl();
    props.setContact("Name", "Mail@yahoo.com", "+431585", "Thurngasse 8, 1090 Wien");
   
    assertEquals("Thurngasse 8, 1090 Wien", props.getContactAddress());
    assertEquals("Mail@yahoo.com", props.getContactMail());
    assertEquals("Name", props.getContactName());
    assertEquals("+431585", props.getContactTel());
  }
View Full Code Here

    assertEquals("+431585", props.getContactTel());
  }
 
 
  public void testExperimentApproach(){
    BasicProperties props = new BasicPropertiesImpl();
    AdminManager adminManager = AdminManagerImpl.getInstance();
    try {
      props.setExperimentApproach(
          adminManager.getExperimentTypeID("simple migration"));
    } catch (InvalidInputException e) {
      assertEquals(true,false);
    }
    assertEquals(adminManager.getExperimentTypeID("simple migration"), props.getExperimentApproach());
 
    //Test2:
    String sTypeID = adminManager.getExperimentTypeID("complex workflow");
    try {
      props.setExperimentApproach(sTypeID);
    } catch (InvalidInputException e) {
      assertEquals(true,false);
    }
    assertEquals("complex workflow", props.getExperimentApproachName(sTypeID));
   
   
    //Test3:
    sTypeID = adminManager.getExperimentTypeID("novalidtypename");
    try {
      props.setExperimentApproach(sTypeID);
      assertEquals(false,true);
    } catch (InvalidInputException e) {
      assertEquals(true,true);
    }   
  }
View Full Code Here

    }   
  }
 
 
  public void testExperimenter(){
    BasicProperties props = new BasicPropertiesImpl();
    props.setExperimenter("TestUser1");
   
    assertEquals("TestUser1",props.getExperimenter());
   
  }
View Full Code Here

   
  }
 
 
  public void testExperimentedObjectType(){
    BasicProperties props = new BasicPropertiesImpl();
  //Test1:
    try {
      props.setExperimentedObjectType("text/plain");
    } catch (InvalidInputException e) {
      assertEquals(true,false);
    }
    List<String> vTypes = new Vector<String>();
    vTypes = props.getExperimentedObjectTypes();
    assertEquals(1,vTypes.size());
    assertTrue(vTypes.contains("text/plain"));
 
  //Test2:
    vTypes = new Vector<String>();
    vTypes.add("text/plain");
    vTypes.add("text/plain");
    vTypes.add("text/html");
    vTypes.add("image/gif");
    try {
      props.setExperimentedObjectTypes(vTypes);
    } catch (InvalidInputException e) {
      assertEquals(true,false);
    }
    vTypes = props.getExperimentedObjectTypes();
    assertEquals(3,vTypes.size());
    assertTrue(vTypes.contains("text/html"));
    assertTrue(vTypes.contains("image/gif"));
   
  //Test3:
    vTypes = new Vector<String>();
    vTypes.add("text/html");
    vTypes.add("image\\gif");
    vTypes.add("image/gif");
    try {
      props.setExperimentedObjectTypes(vTypes);
      assertEquals(true,false);
    } catch (InvalidInputException e) {
      assertEquals(true,true);
    }
    vTypes = props.getExperimentedObjectTypes();
    assertEquals(1,vTypes.size());
    assertTrue(vTypes.contains("text/html"));
    assertTrue(!vTypes.contains("image\\gif"));
    assertTrue(!vTypes.contains("image/gif"));
   
View Full Code Here

    assertTrue(!vTypes.contains("image/gif"));
   
  }
 
  public void testExperimentReference(){
    BasicProperties props = new BasicPropertiesImpl();

    //Test1:
    long l1 = 123;
    props.addExperimentReference(l1);

    assertTrue(props.getExperimentReferences().contains(l1));
    assertEquals(1,props.getExperimentReferences().size());

    //Test2:
    long l2 = 234;
    props.addExperimentReference(l2);
    assertTrue(props.getExperimentReferences().contains(l1));
    assertTrue(props.getExperimentReferences().contains(l2));
    assertEquals(2,props.getExperimentReferences().size());

    //Test3: 1/4
    TestbedManager manager = TestbedManagerImpl.getInstance();
    Experiment exp = manager.createNewExperiment();
    props.setExperimentReference(exp);

    assertTrue(manager.containsExperiment(exp.getEntityID()));
    assertEquals(1, props.getExperimentReferences().size());
    assertTrue(props.getExperimentReferences().contains(exp.getEntityID()));
    manager.removeExperiment(exp.getEntityID());

    //Test3: 2/4
    Experiment exp2 = manager.createNewExperiment();
    props.setExperimentReference(exp2.getEntityID());

    assertTrue(manager.containsExperiment(exp2.getEntityID()));
    assertEquals(1, props.getExperimentReferences().size());
    assertTrue(props.getExperimentReferences().contains(exp2.getEntityID()));
    manager.removeExperiment(exp2.getEntityID());

    //Test3: 3/4
    Experiment exp3 = manager.createNewExperiment();
    Experiment exp4 = manager.createNewExperiment();
    Experiment[] exparray = {exp3, exp4};
    props.setExperimentReferences(exparray);

    assertTrue(manager.containsExperiment(exp3.getEntityID()));
    assertTrue(manager.containsExperiment(exp4.getEntityID()));
    assertEquals(2, props.getExperimentReferences().size());
    assertTrue(props.getExperimentReferences().contains(exp3.getEntityID()));
    assertTrue(props.getExperimentReferences().contains(exp4.getEntityID()));
    manager.removeExperiment(exp3.getEntityID());
    manager.removeExperiment(exp4.getEntityID());

    //Test: 4/4
    List<Long> refIDs = new Vector<Long>();
    Experiment exp5 = manager.createNewExperiment();
    Experiment exp6 = manager.createNewExperiment();
    refIDs.add(exp5.getEntityID());
    refIDs.add(exp6.getEntityID());
    props.setExperimentReferences(refIDs);

    assertTrue(manager.containsExperiment(exp5.getEntityID()));
    assertTrue(manager.containsExperiment(exp6.getEntityID()));
    assertEquals(2, props.getExperimentReferences().size());
    assertTrue(props.getExperimentReferences().contains(exp5.getEntityID()));
    assertTrue(props.getExperimentReferences().contains(exp6.getEntityID()));

    //Test: 5
    HashMap<Long,Experiment> refs = (HashMap<Long,Experiment>)props.getReferencedExperiments();
    assertEquals(2, props.getReferencedExperimentIDs().size());
    assertTrue(props.getReferencedExperimentIDs().contains(exp5.getEntityID()));
    assertTrue(refs.get(exp5.getEntityID()).getEntityID()== exp5.getEntityID());
    manager.removeExperiment(exp5.getEntityID());
    manager.removeExperiment(exp6.getEntityID());
   
  }
View Full Code Here

   
  }
 
 
  public void testInvolvedUsers(){
    BasicProperties props = new BasicPropertiesImpl();
    //Test1:
    props.addInvolvedUser("TestUser1");
    props.addInvolvedUser("TestUser2");
   
    assertEquals(2, props.getInvolvedUserIds().size());
    assertTrue(props.getInvolvedUserIds().contains("TestUser1"));
   
    //Test2:
    List<String> userIDs = new Vector<String>();
    userIDs.add("TestUser3");
    userIDs.add("TestUser4");
    userIDs.add("TestUser4");
    props.addInvolvedUsers(userIDs);

    assertEquals(4, props.getInvolvedUserIds().size());
    assertTrue(props.getInvolvedUserIds().contains("TestUser1"));
    assertTrue(props.getInvolvedUserIds().contains("TestUser3"));
   
    //Test3:
    props.removeInvolvedUser("TestUser1");
   
    assertEquals(3, props.getInvolvedUserIds().size());
    assertTrue(!props.getInvolvedUserIds().contains("TestUser1"));
    assertTrue(props.getInvolvedUserIds().contains("TestUser3"));

    //Test4:
    List<String> userIDs2 = new Vector<String>();
    userIDs2.add("TestUser3");
    userIDs2.add("TestUser3");
    props.removeInvolvedUsers(userIDs2);

    assertEquals(2, props.getInvolvedUserIds().size());
    assertTrue(props.getInvolvedUserIds().contains("TestUser2"));
    assertTrue(props.getInvolvedUserIds().contains("TestUser4"));
    assertTrue(!props.getInvolvedUserIds().contains("TestUser3"));
  }
View Full Code Here

TOP

Related Classes of eu.planets_project.tb.api.model.BasicProperties

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.