Projects >> Wildbook >>6b69b19cae1e9097cc5175641306462cf2850084

Chunk
Conflicting content
    this(enc, 130);
  }

<<<<<<< HEAD
  public EncounterLite(Encounter enc, double dorsalRotationInDegree) {
    if(enc.getDate()!=null){
      this.date = enc.getDate();
=======
  public EncounterLite(Encounter enc) {
    this.date = enc.getDate();
    this.encounterNumber = enc.getEncounterNumber();
    if(enc.getIndividualID()!=null){
      this.belongsToMarkedIndividual = enc.getIndividualID();
    }
    if(enc.getSex()!=null){
      this.sex = enc.getSex();
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
    }
    
    if(enc.getDateInMilliseconds()!=null){
Solution content
    this(enc, 130);
  }

  public EncounterLite(Encounter enc, double dorsalRotationInDegree) {
    if(enc.getDate()!=null){
      this.date = enc.getDate();
    }
    
    if(enc.getDateInMilliseconds()!=null){
File
EncounterLite.java
Developer's decision
Version 1
Kind of conflict
Attribute
If statement
Method invocation
Method signature
Chunk
Conflicting content
  }
  */
  
<<<<<<< HEAD

    
=======
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991

    
Solution content
  }
  */
  

    
File
GridManager.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
package org.ecocean.grid;

import org.ecocean.Encounter;
<<<<<<< HEAD
import org.ecocean.CommonConfiguration;
=======
import org.ecocean.Occurrence;
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
import org.ecocean.Shepherd;
import org.ecocean.Util;
import org.ecocean.identity.IBEISIA;
Solution content
package org.ecocean.grid;

import org.ecocean.Encounter;
import org.ecocean.CommonConfiguration;
import org.ecocean.Shepherd;
import org.ecocean.Util;
import org.ecocean.identity.IBEISIA;
File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
    String baseUrl = "http://unknown-url.example.com";
  String context="context0";
  String jdoql="SELECT FROM org.ecocean.Encounter";
<<<<<<< HEAD
  String algorithms="";
  String genus="";
  String species="";
=======
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991

  /**
   * Constructor to create a new thread object
Solution content
    String baseUrl = "http://unknown-url.example.com";
  String context="context0";
  String jdoql="SELECT FROM org.ecocean.Encounter";
  String algorithms="";
  String genus="";
  String species="";

  /**
   * Constructor to create a new thread object
File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
Attribute
Chunk
Conflicting content
  /**
   * Constructor to create a new thread object
   */
<<<<<<< HEAD
  public ScanWorkItemCreationThread(String taskID, boolean rightSide, String encounterNum, boolean writeThis, String context, String jdoql, String genus, String species, ServletContext sctx, HttpServletRequest request) {
=======
  public ScanWorkItemCreationThread(String taskID, boolean rightSide, String encounterNum, boolean writeThis, String context, String jdoql) {
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
    this.taskID = taskID;
    this.writeThis = writeThis;
    this.rightSide = rightSide;
Solution content
  /**
   * Constructor to create a new thread object
   */
  public ScanWorkItemCreationThread(String taskID, boolean rightSide, String encounterNum, boolean writeThis, String context, String jdoql, String genus, String species, ServletContext sctx, HttpServletRequest request) {
    this.taskID = taskID;
    this.writeThis = writeThis;
    this.rightSide = rightSide;
File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
Method signature
Chunk
Conflicting content
    gm = GridManagerFactory.getGridManager();
    threadCreationObject = new Thread(this, ("scanWorkItemCreation_" + taskID));
    this.context=context;
<<<<<<< HEAD
    try {
        baseUrl = CommonConfiguration.getServerURL(request, request.getContextPath());
    } catch (URISyntaxException ex) {
        System.out.println("ScanWorkItemCreationThread() failed to obtain baseUrl: " + ex.toString());
    }
System.out.println("baseUrl --> " + baseUrl);
=======
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
    
    if((jdoql!=null)&&(!jdoql.trim().equals(""))){
      this.jdoql=jdoql;
Solution content
System.out.println("baseUrl --> " + baseUrl);
      this.jdoql=jdoql;
    gm = GridManagerFactory.getGridManager();
    threadCreationObject = new Thread(this, ("scanWorkItemCreation_" + taskID));
    this.context=context;
    try {
        baseUrl = CommonConfiguration.getServerURL(request, request.getContextPath());
    } catch (URISyntaxException ex) {
        System.out.println("ScanWorkItemCreationThread() failed to obtain baseUrl: " + ex.toString());
    }
    
    if((jdoql!=null)&&(!jdoql.trim().equals(""))){
File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
Method invocation
Try statement
Chunk
Conflicting content
    if((jdoql!=null)&&(!jdoql.trim().equals(""))){
      this.jdoql=jdoql;
    }
<<<<<<< HEAD
    if(CommonConfiguration.getProperty("algorithms", context)!=null){
      algorithms=CommonConfiguration.getProperty("algorithms", context);
    }
    
    
    if(genus!=null){this.genus=genus;}
    if(species!=null){this.species=species;}
=======
    
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
  }

Solution content
    if((jdoql!=null)&&(!jdoql.trim().equals(""))){
      this.jdoql=jdoql;
    }
    if(CommonConfiguration.getProperty("algorithms", context)!=null){
      algorithms=CommonConfiguration.getProperty("algorithms", context);
    }
    
    
    if(genus!=null){this.genus=genus;}
    if(species!=null){this.species=species;}
  }

File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
If statement
Chunk
Conflicting content
    System.out.println("Successfully created the scanTask shell!");
    //now, add the workItems
    myShepherd.beginDBTransaction();
<<<<<<< HEAD
    //Query query=null;
    Collection c=null;
    try {
      
/*  NOTE: our new way to find suitable encounters is below -- TODO this needs to account for empty genus & species!!!
      if(genus.equals("")){
        query=myShepherd.getPM().newQuery(jdoql);
        c = (Collection) (query.execute());
      }
      else{
        //c= myShepherd.getAllEncountersForSpeciesWithSpots(genus, species);
        String keywordQueryString="SELECT FROM org.ecocean.Encounter WHERE spots != null && genus == '"+genus+"' && specificEpithet == '"+species+"'";
        query=myShepherd.getPM().newQuery(keywordQueryString);
        c = (Collection) (query.execute());
      }
      //System.out.println("Num scans to do: "+c.size());
      Iterator encounters = c.iterator();
*/
      
        ArrayList encounters = Encounter.getEncountersForMatching(Util.taxonomyString(genus, species), myShepherd);
=======
    Query query=null;
    try {
      //Iterator encounters = myShepherd.getAllEncountersNoQuery();
      
      query=myShepherd.getPM().newQuery(jdoql);
      Collection c = (Collection) (query.execute());
      System.out.println("Num scans to do: "+c.size());
      Iterator encounters = c.iterator();
      

      
      int count = 0;

      while (encounters.hasNext()) {
        System.out.println("     Iterating encounters to create scanWorkItems...");
        Encounter enc = (Encounter) encounters.next();
        if (!enc.getEncounterNumber().equals(encounterNumber)) {
          String wiIdentifier = taskID + "_" + (new Integer(count)).toString();
          if (rightSide && (enc.getRightSpots() != null) && (enc.getRightSpots().size() > 0)) {
            //add the workItem
            ScanWorkItem swi = new ScanWorkItem(myShepherd.getEncounter(encounterNumber), enc, wiIdentifier, taskID, props2);
            String uniqueNum = swi.getUniqueNumber();

            gm.addWorkItem(swi);

            //System.out.println("Added a new right-side scan task!");
            count++;
          } else if (!rightSide && (enc.getSpots() != null) && (enc.getSpots().size() > 0)) {
            //add the workItem
            ScanWorkItem swi = new ScanWorkItem(myShepherd.getEncounter(encounterNumber), enc, wiIdentifier, taskID, props2);

            String uniqueNum = swi.getUniqueNumber();
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991

        //we kick of IBEIS first, so it has (plenty of!) time to finish
        ArrayList qencs = new ArrayList();
Solution content
    System.out.println("Successfully created the scanTask shell!");
    //now, add the workItems
    myShepherd.beginDBTransaction();
    //Query query=null;
    Collection c=null;
    try {
      
/*  NOTE: our new way to find suitable encounters is below -- TODO this needs to account for empty genus & species!!!
      if(genus.equals("")){
        query=myShepherd.getPM().newQuery(jdoql);
        c = (Collection) (query.execute());
      }
      else{
        //c= myShepherd.getAllEncountersForSpeciesWithSpots(genus, species);
        String keywordQueryString="SELECT FROM org.ecocean.Encounter WHERE spots != null && genus == '"+genus+"' && specificEpithet == '"+species+"'";
        query=myShepherd.getPM().newQuery(keywordQueryString);
        c = (Collection) (query.execute());
      }
      //System.out.println("Num scans to do: "+c.size());
      Iterator encounters = c.iterator();
*/
      
        ArrayList encounters = Encounter.getEncountersForMatching(Util.taxonomyString(genus, species), myShepherd);

        //we kick of IBEIS first, so it has (plenty of!) time to finish
        ArrayList qencs = new ArrayList();
File
ScanWorkItemCreationThread.java
Developer's decision
Version 1
Kind of conflict
Attribute
Cast expression
Comment
If statement
Method invocation
Try statement
Variable
While statement
Chunk
Conflicting content
//System.out.println("qry -> " + queryString);
		Shepherd myShepherd = new Shepherd(context);
		Query query = myShepherd.getPM().newQuery(queryString);
<<<<<<< HEAD
    //ArrayList got = myShepherd.getAllOccurrences(query);
		ArrayList occurs=myShepherd.getAllOccurrences(query);
		query.closeAll();
		return occurs;
=======
    //List got = myShepherd.getAllOccurrences(query);
    return myShepherd.getAllOccurrences(query);
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
	}

	public static Collaboration collaborationBetweenUsers(String context, String u1, String u2) {
Solution content
//System.out.println("qry -> " + queryString);
		Shepherd myShepherd = new Shepherd(context);
		Query query = myShepherd.getPM().newQuery(queryString);
    //ArrayList got = myShepherd.getAllOccurrences(query);
		List occurs=myShepherd.getAllOccurrences(query);
		query.closeAll();
		return occurs;
	}

	public static Collaboration collaborationBetweenUsers(String context, String u1, String u2) {
File
Collaboration.java
Developer's decision
Manual
Kind of conflict
Comment
Method invocation
Return statement
Variable
Chunk
Conflicting content
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
<<<<<<< HEAD
import org.ecocean.CommonConfiguration;
import org.ecocean.Util;
import org.ecocean.Encounter;
import org.ecocean.Measurement;
import org.ecocean.Shepherd;
import org.ecocean.media.*;
import org.ecocean.ShepherdProperties;
import org.ecocean.SinglePhotoVideo;
=======
import org.ecocean.*;
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
import org.ecocean.tag.AcousticTag;
import org.ecocean.tag.MetalTag;
import org.ecocean.tag.SatelliteTag;
Solution content
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.ecocean.CommonConfiguration;
import org.ecocean.Util;
import org.ecocean.Encounter;
import org.ecocean.Measurement;
import org.ecocean.Shepherd;
import org.ecocean.media.*;
import org.ecocean.ShepherdProperties;
import org.ecocean.SinglePhotoVideo;
import org.ecocean.tag.AcousticTag;
import org.ecocean.tag.MetalTag;
import org.ecocean.tag.SatelliteTag;
File
EncounterForm.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
            else{


            ThreadPoolExecutor es = SharkGridThreadExecutorService.getExecutorService();
<<<<<<< HEAD
            
          //launch EC2 instances
            es.execute(new EC2RequestThread());
            
            //now build our jobs for the task
            if(jdoql.equals("")){
              es.execute(new ScanWorkItemCreationThread(taskIdentifier, isRightScan, request.getParameter("encounterNumber"), writeThis,context, jdoql, genus, species, getServletContext(), request));
              
            }
              es.execute(new ScanWorkItemCreationThread(taskIdentifier, isRightScan, request.getParameter("encounterNumber"), writeThis,context, jdoql, null, null, getServletContext(), request));
            }
=======
            es.execute(new ScanWorkItemCreationThread(taskIdentifier, isRightScan, request.getParameter("encounterNumber"), writeThis,context,""));

>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991

          } catch (Exception e) {
            System.out.println("I failed while constructing the workItems for a new scanTask.");
Solution content

            ThreadPoolExecutor es = SharkGridThreadExecutorService.getExecutorService();
            
          //launch EC2 instances
            es.execute(new EC2RequestThread());
            
            //now build our jobs for the task
            if(jdoql.equals("")){
              es.execute(new ScanWorkItemCreationThread(taskIdentifier, isRightScan, request.getParameter("encounterNumber"), writeThis,context, jdoql, genus, species, getServletContext(), request));
              
            }
            else{
              es.execute(new ScanWorkItemCreationThread(taskIdentifier, isRightScan, request.getParameter("encounterNumber"), writeThis,context, jdoql, null, null, getServletContext(), request));
            }

          } catch (Exception e) {
            System.out.println("I failed while constructing the workItems for a new scanTask.");
File
ScanTaskHandler.java
Developer's decision
Version 1
Kind of conflict
Comment
If statement
Method invocation
Chunk
Conflicting content
        e.printStackTrace();
        statusText = "failure";
      }
<<<<<<< HEAD
      finally{
        response.setContentType("text/plain");
        out = response.getWriter();
        out.println(statusText);
        out.close();
=======

    } else {

      //this is how to handle a TuningTask
      String statusText = "success";
      System.out.println("writeOutScanTask - TuningTask: I am starting up.");

      //set up our StringBuffers for the test and training files
      StringBuffer train = new StringBuffer();
      StringBuffer test = new StringBuffer();

      //let's get our boosting scores in.
      String[] predictInput = new String[10];

      myShepherd.beginDBTransaction();
      ScanTask st2 = null;
      try {

        if (request.getParameter("number").equals("TuningTask")) {
          st2 = myShepherd.getScanTask("TuningTask");
        } else {
          st2 = myShepherd.getScanTask("FalseMatchTask");
        }

        st2.setFinished(true);

        long time = System.currentTimeMillis();
        st2.setEndTime(time);


        //let's write out the results

        //File file=new File((new File(".")).getCanonicalPath()+File.separator+"webapps"+File.separator+"ROOT"+File.separator+"appadmin"+File.separator+request.getParameter("number")+"_tuningTaskOutput.xls");
        /**
         File file=new File(getServletContext().getRealPath(("/appadmin/"+request.getParameter("number")+"_tuningTaskOutput.xls")));
         WritableWorkbook workbook = Workbook.createWorkbook(file);
         WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT);
         WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
         WritableSheet sheet = workbook.createSheet(request.getParameter("number")+" Output", 0);

         //add the label row
         Label label0 = new Label(0, 0, "Encounter A");

         Label label1 = new Label(1, 0, "Encounter B");

         Label label2 = new Label(2, 0, "Shark");

              boostString = boostString + ", 1.0";
         Label label2a = new Label(3, 0, "Groth: Fraction Matched Triangles");

         Label label3 = new Label(4, 0, "Groth: Match Score");

         Label label5 = new Label(5, 0, "I3S Match Score");

         Label label6 = new Label(6, 0, "RefA 1x");

         Label label7 = new Label(7, 0, "RefA 1y");

         Label label8 = new Label(8, 0, "RefA 2x");

         Label label9 = new Label(9, 0, "RefA 2y");

         Label label10 = new Label(10, 0, "RefA 3x");

         Label label11 = new Label(11, 0, "RefA 3y");

         Label label6b = new Label(12, 0, "RefB 1x");

         Label label7b = new Label(13, 0, "RefB 1y");

         Label label8b = new Label(14, 0, "RefB 2x");

         Label label9b = new Label(15, 0, "RefB 2y");

         Label label10b = new Label(16, 0, "RefB 3x");

         Label label11b = new Label(17, 0, "RefB 3y");


         Label label12 = new Label(18, 0, "Spot used for A?");

         Label label13 = new Label(19, 0, "Spot used for B?");

         Label label13y = new Label(20, 0, "Side");


         //boosting scores
         Label label14 = new Label(21, 0, "Boost - match score");

         Label label15 = new Label(22, 0, "Boost - not score");


         if(!request.getParameter("number").equals("TuningTask")){

         sheet.addCell(label15);
         sheet.addCell(label14);
         sheet.addCell(label13y);
         sheet.addCell(label13);
         sheet.addCell(label12);
         sheet.addCell(label11b);
         sheet.addCell(label10b);
         sheet.addCell(label9b);
         sheet.addCell(label8b);
         sheet.addCell(label7b);
         sheet.addCell(label6b);
         sheet.addCell(label11);
         sheet.addCell(label10);
         sheet.addCell(label9);
         sheet.addCell(label8);
         sheet.addCell(label7);
         sheet.addCell(label6);
         sheet.addCell(label5);
         sheet.addCell(label3);
         sheet.addCell(label2a);
         sheet.addCell(label2);
         sheet.addCell(label1);
         sheet.addCell(label0);

         }
         */

        ArrayList wis = null;
        if (request.getParameter("number").equals("TuningTask")) {
          wis = gm.getRemainingWorkItemsForTask("TuningTask");
        } else {
          wis = gm.getRemainingWorkItemsForTask("FalseMatchTask");

          //System.out.println("wis size in writeOutScanTask is: " + wis.size());

        }

        ArrayList wirs = null;
        if (request.getParameter("number").equals("TuningTask")) {
          wirs = gm.getResultsForTask("TuningTask");
        } else {
          wirs = gm.getResultsForTask("FalseMatchTask");
        }


        System.out.println("writeOutScanTask: got my scanTask...");
        int resultSize = wirs.size();
        for (int i = 1; i < (resultSize + 1); i++) {

          String boostString = "";

          //get the objects we need to populate intelligent results
          MatchObject mo = wirs.get(i - 1).getResult();
          //scanWorkItem ttt=wirs.get(i-1).
          ScanWorkItem swi = getWI4MO(wirs.get(i - 1), wis);
          Encounter encA = myShepherd.getEncounter(swi.getNewEncNumber());
          Encounter encB = myShepherd.getEncounter(swi.getExistingEncNumber());


          //boost sex
          if ((encA.getSex()!=null)&&(encB.getSex()!=null)&&(encA.getSex().equals(encB.getSex()))) {
            boostString += (encA.getSex() + ",");
            predictInput[0] = encA.getSex();
          } 
          else {
            boostString += "unknown,";
            predictInput[0] = "unknwon";
          }


          //boost locationCode
          String locCodeA = encA.getLocationCode().trim();
          String locCodeB = encB.getLocationCode().trim();

          boostString += (locCodeA + "," + locCodeB + ",");
          predictInput[1] = locCodeA.trim();
          predictInput[2] = locCodeB.trim();

          //add the label row
          /*Label label0a = new Label(0, i, encA.getEncounterNumber());

               Label label1a = new Label(1, i, encB.getEncounterNumber());

            try {
               Label label2aaa = new Label(2, i, mo.getIndividualName());

               Label label2aa = new Label(3, i, Double.toString(mo.adjustedMatchValue));

               Label label3a = new Label(4, i, Double.toString((mo.getMatchValue()*mo.getAdjustedMatchValue())));

               Label label5a = new Label(5, i, Double.toString(mo.i3sMatchValue));
               */

          //boost I3S score
          boostString = boostString + mo.i3sMatchValue + ",";
          predictInput[3] = Double.toString(mo.i3sMatchValue);

          //boost Groth score
          boostString = boostString + (mo.getMatchValue()) + ",";
          predictInput[4] = Double.toString((mo.getMatchValue()));

          boostString = boostString + mo.getAdjustedMatchValue() + ",";
          predictInput[5] = Double.toString((mo.getAdjustedMatchValue()));

          String logM = "";
          try {
            logM = (new Double(mo.getLogMStdDev()).toString());
          } catch (java.lang.NumberFormatException nfe) {
            logM = "0.01";
          }
          boostString = boostString + logM + ",";
          predictInput[6] = logM;

          //boost time difference in absolute years
          boostString = boostString + Math.abs((encA.getYear() - encB.getYear())) + ",";
          predictInput[7] = Integer.toString(Math.abs((encA.getYear() - encB.getYear())));

          //boost num matching keywords
          List keywords = myShepherd.getKeywordsInCommon(encA.getEncounterNumber(), encB.getEncounterNumber());
          int keywordsSize = keywords.size();
          boostString = boostString + keywordsSize + ",";
          predictInput[8] = Integer.toString(keywordsSize);

          String sizeDiffString = "unknown";
          if ((encA.getSizeAsDouble()!=null)&&(encB.getSizeAsDouble()!=null)&&(encA.getSize() > 0) && (encB.getSize() > 0)) {
            double sizeDiff = Math.abs((encA.getSize() - encB.getSize()));
            if (sizeDiff <= 2.0) {
              sizeDiffString = "small";
            } else {
              sizeDiffString = "large";
            }
          }
          predictInput[9] = sizeDiffString;
          boostString = boostString + sizeDiffString + ",";

          //boost the label
          if (request.getParameter("number").equals("TuningTask")) {
            boostString = boostString + "match";
          } else {
            boostString = boostString + "not";
          }

          //add weight
          //if((request.getParameter("boostWeight")!=null)&&(!request.getParameter("boostWeight").equals(""))){
          if (request.getParameter("number").equals("TuningTask")) {
            if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) < 30) {
              boostString = boostString + ", 2.0";
            } else {
            }
          } else {
            if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) > 50) {
              boostString = boostString + ",2.0";
            } else {
              boostString = boostString + ", 1.0";
            }


          }

          //numSpotsDiff
          int numSpotsDiff = 0;
          if (swi.rightScan) {
            numSpotsDiff = Math.abs(encA.getNumRightSpots() - encB.getNumRightSpots());
          } else {
            numSpotsDiff = Math.abs(encA.getNumSpots() - encB.getNumSpots());
          }
          boostString = boostString + ", " + Integer.toString(numSpotsDiff);

          boostString = boostString + ";";

          //add to the right boosting area, left sides are used for training, right sides are used for testing
          if (swi.rightScan) {
            test.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
            test.append((boostString + "\n"));
          } else {
            train.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
            train.append((boostString + "\n"));
          }

          //now let's populate the reference spots

          String ref1x_A = "";
          String ref1y_A = "";
          String ref2x_A = "";
          String ref2y_A = "";
          String ref3x_A = "";
          String ref3y_A = "";
          String ref1x_B = "";
          String ref1y_B = "";
          String ref2x_B = "";
          String ref2y_B = "";
          String ref3x_B = "";
          String ref3y_B = "";

          //populate these for encA
          if (swi.rightScan) {
            if ((encA.getRightReferenceSpots() != null) && (encA.getRightReferenceSpots().size() > 0)) {

              ref1x_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidX());
              ref1y_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidY());
              ref2x_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidX());
              ref2y_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidY());
              ref3x_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidX());
              ref3y_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidY());

            }

          } else {
            if ((encA.getLeftReferenceSpots() != null) && (encA.getLeftReferenceSpots().size() > 0)) {

              ref1x_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidX());
              ref1y_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidY());
              ref2x_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidX());
              ref2y_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidY());
              ref3x_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidX());
              ref3y_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidY());

            }

          }

          //populate reference spots for encB
          if (swi.rightScan) {
            if ((encB.getRightReferenceSpots() != null) && (encB.getRightReferenceSpots().size() > 0)) {

              ref1x_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidX());
              ref1y_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidY());
              ref2x_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidX());
              ref2y_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidY());
              ref3x_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidX());
              ref3y_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidY());

            }

          } else {
            if ((encB.getLeftReferenceSpots() != null) && (encB.getLeftReferenceSpots().size() > 0)) {

              ref1x_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidX());
              ref1y_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidY());
              ref2x_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidX());
              ref2y_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidY());
              ref3x_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidX());
              ref3y_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidY());

            }

          }


          //Spot maps
          String aSpot = "false";
          String bSpot = "false";
          if (swi.rightScan) {
            try {
              if (encB.rightSpotImageFileName.endsWith("-mapped.jpg")) {
                bSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encB.getEncounterNumber());
            }
              if (encA.rightSpotImageFileName.endsWith("-mapped.jpg")) {
                aSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encA.getEncounterNumber());
            }

          } else {
            try {
              if (encB.spotImageFileName.endsWith("-mapped.jpg")) {
                bSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the spotImageFileName for encounter " + encB.getEncounterNumber());
            }
            try {
              if (encA.spotImageFileName.endsWith("-mapped.jpg")) {
                aSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the spotImageFileName for encounter " + encA.getEncounterNumber());
            }

          }


          String side = "l";
          if (swi.rightScan) {
            side = "r";
          }


        }


        //write out the Excel file
        if (!request.getParameter("number").equals("TuningTask")) {
          //finalize(workbook);
          //workbook.close();
        }

        //let's finalize the boosting files

        writeBoostFiles(train, test, request.getParameter("number"));


        myShepherd.commitDBTransaction();
        myShepherd.closeDBTransaction();

        if (request.getParameter("number").equals("TuningTask")) {
          String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=TuningTask");
          response.sendRedirect(resultsURL);
        } else {
          String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=FalseMatchTask");
          response.sendRedirect(resultsURL);
        }

      } catch (Exception e) {
        myShepherd.rollbackDBTransaction();
        System.out.println("writeOutScanTask registered the following error...");
        e.printStackTrace();
        statusText = "failure";
>>>>>>> 4f75a39030e763ff5ad61ee00b3accc4be762991
      }

  }
Solution content
        e.printStackTrace();
        statusText = "failure";
      }

    } else {

      //this is how to handle a TuningTask
      String statusText = "success";
      System.out.println("writeOutScanTask - TuningTask: I am starting up.");

      //set up our StringBuffers for the test and training files
      StringBuffer train = new StringBuffer();
      StringBuffer test = new StringBuffer();

      //let's get our boosting scores in.
      String[] predictInput = new String[10];

      myShepherd.beginDBTransaction();
      ScanTask st2 = null;
      try {

        if (request.getParameter("number").equals("TuningTask")) {
          st2 = myShepherd.getScanTask("TuningTask");
        } else {
          st2 = myShepherd.getScanTask("FalseMatchTask");
        }

        st2.setFinished(true);

        long time = System.currentTimeMillis();
        st2.setEndTime(time);


        //let's write out the results

        //File file=new File((new File(".")).getCanonicalPath()+File.separator+"webapps"+File.separator+"ROOT"+File.separator+"appadmin"+File.separator+request.getParameter("number")+"_tuningTaskOutput.xls");
        /**
         File file=new File(getServletContext().getRealPath(("/appadmin/"+request.getParameter("number")+"_tuningTaskOutput.xls")));
         WritableWorkbook workbook = Workbook.createWorkbook(file);
         WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT);
         WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER);
         WritableSheet sheet = workbook.createSheet(request.getParameter("number")+" Output", 0);

         //add the label row
         Label label0 = new Label(0, 0, "Encounter A");

         Label label1 = new Label(1, 0, "Encounter B");

         Label label2 = new Label(2, 0, "Shark");

         Label label2a = new Label(3, 0, "Groth: Fraction Matched Triangles");

         Label label3 = new Label(4, 0, "Groth: Match Score");

         Label label5 = new Label(5, 0, "I3S Match Score");

         Label label6 = new Label(6, 0, "RefA 1x");

         Label label7 = new Label(7, 0, "RefA 1y");

         Label label8 = new Label(8, 0, "RefA 2x");

         Label label9 = new Label(9, 0, "RefA 2y");

         Label label10 = new Label(10, 0, "RefA 3x");

         Label label11 = new Label(11, 0, "RefA 3y");

         Label label6b = new Label(12, 0, "RefB 1x");

         Label label7b = new Label(13, 0, "RefB 1y");

         Label label8b = new Label(14, 0, "RefB 2x");

         Label label9b = new Label(15, 0, "RefB 2y");

         Label label10b = new Label(16, 0, "RefB 3x");

         Label label11b = new Label(17, 0, "RefB 3y");


         Label label12 = new Label(18, 0, "Spot used for A?");

         Label label13 = new Label(19, 0, "Spot used for B?");

         Label label13y = new Label(20, 0, "Side");


         //boosting scores
         Label label14 = new Label(21, 0, "Boost - match score");

         Label label15 = new Label(22, 0, "Boost - not score");


         if(!request.getParameter("number").equals("TuningTask")){

         sheet.addCell(label15);
         sheet.addCell(label14);
         sheet.addCell(label13y);
         sheet.addCell(label13);
         sheet.addCell(label12);
         sheet.addCell(label11b);
         sheet.addCell(label10b);
         sheet.addCell(label9b);
         sheet.addCell(label8b);
         sheet.addCell(label7b);
         sheet.addCell(label6b);
         sheet.addCell(label11);
         sheet.addCell(label10);
         sheet.addCell(label9);
         sheet.addCell(label8);
         sheet.addCell(label7);
         sheet.addCell(label6);
         sheet.addCell(label5);
         sheet.addCell(label3);
         sheet.addCell(label2a);
         sheet.addCell(label2);
         sheet.addCell(label1);
         sheet.addCell(label0);

         }
         */

        ArrayList wis = null;
        if (request.getParameter("number").equals("TuningTask")) {
          wis = gm.getRemainingWorkItemsForTask("TuningTask");
        } else {
          wis = gm.getRemainingWorkItemsForTask("FalseMatchTask");

          //System.out.println("wis size in writeOutScanTask is: " + wis.size());

        }

        ArrayList wirs = null;
        if (request.getParameter("number").equals("TuningTask")) {
          wirs = gm.getResultsForTask("TuningTask");
        } else {
          wirs = gm.getResultsForTask("FalseMatchTask");
        }


        System.out.println("writeOutScanTask: got my scanTask...");
        int resultSize = wirs.size();
        for (int i = 1; i < (resultSize + 1); i++) {

          String boostString = "";

          //get the objects we need to populate intelligent results
          MatchObject mo = wirs.get(i - 1).getResult();
          //scanWorkItem ttt=wirs.get(i-1).
          ScanWorkItem swi = getWI4MO(wirs.get(i - 1), wis);
          Encounter encA = myShepherd.getEncounter(swi.getNewEncNumber());
          Encounter encB = myShepherd.getEncounter(swi.getExistingEncNumber());


          //boost sex
          if ((encA.getSex()!=null)&&(encB.getSex()!=null)&&(encA.getSex().equals(encB.getSex()))) {
            boostString += (encA.getSex() + ",");
            predictInput[0] = encA.getSex();
          } 
          else {
            boostString += "unknown,";
            predictInput[0] = "unknwon";
          }


          //boost locationCode
          String locCodeA = encA.getLocationCode().trim();
          String locCodeB = encB.getLocationCode().trim();

          boostString += (locCodeA + "," + locCodeB + ",");
          predictInput[1] = locCodeA.trim();
          predictInput[2] = locCodeB.trim();

          //add the label row
          /*Label label0a = new Label(0, i, encA.getEncounterNumber());

               Label label1a = new Label(1, i, encB.getEncounterNumber());

               Label label2aaa = new Label(2, i, mo.getIndividualName());

               Label label2aa = new Label(3, i, Double.toString(mo.adjustedMatchValue));

               Label label3a = new Label(4, i, Double.toString((mo.getMatchValue()*mo.getAdjustedMatchValue())));

               Label label5a = new Label(5, i, Double.toString(mo.i3sMatchValue));
               */

          //boost I3S score
          boostString = boostString + mo.i3sMatchValue + ",";
          predictInput[3] = Double.toString(mo.i3sMatchValue);

          //boost Groth score
          boostString = boostString + (mo.getMatchValue()) + ",";
          predictInput[4] = Double.toString((mo.getMatchValue()));

          boostString = boostString + mo.getAdjustedMatchValue() + ",";
          predictInput[5] = Double.toString((mo.getAdjustedMatchValue()));

          String logM = "";
          try {
            logM = (new Double(mo.getLogMStdDev()).toString());
          } catch (java.lang.NumberFormatException nfe) {
            logM = "0.01";
          }
          boostString = boostString + logM + ",";
          predictInput[6] = logM;

          //boost time difference in absolute years
          boostString = boostString + Math.abs((encA.getYear() - encB.getYear())) + ",";
          predictInput[7] = Integer.toString(Math.abs((encA.getYear() - encB.getYear())));

          //boost num matching keywords
          List keywords = myShepherd.getKeywordsInCommon(encA.getEncounterNumber(), encB.getEncounterNumber());
          int keywordsSize = keywords.size();
          boostString = boostString + keywordsSize + ",";
          predictInput[8] = Integer.toString(keywordsSize);

          String sizeDiffString = "unknown";
          if ((encA.getSizeAsDouble()!=null)&&(encB.getSizeAsDouble()!=null)&&(encA.getSize() > 0) && (encB.getSize() > 0)) {
            double sizeDiff = Math.abs((encA.getSize() - encB.getSize()));
            if (sizeDiff <= 2.0) {
              sizeDiffString = "small";
            } else {
              sizeDiffString = "large";
            }
          }
          predictInput[9] = sizeDiffString;
          boostString = boostString + sizeDiffString + ",";

          //boost the label
          if (request.getParameter("number").equals("TuningTask")) {
            boostString = boostString + "match";
          } else {
            boostString = boostString + "not";
          }

          //add weight
          //if((request.getParameter("boostWeight")!=null)&&(!request.getParameter("boostWeight").equals(""))){
          if (request.getParameter("number").equals("TuningTask")) {
            if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) < 30) {
              boostString = boostString + ", 2.0";
            } else {
              boostString = boostString + ", 1.0";
            }
          } else {
            if ((mo.getAdjustedMatchValue() * mo.getMatchValue()) > 50) {
              boostString = boostString + ",2.0";
            } else {
              boostString = boostString + ", 1.0";
            }


          }

          //numSpotsDiff
          int numSpotsDiff = 0;
          if (swi.rightScan) {
            numSpotsDiff = Math.abs(encA.getNumRightSpots() - encB.getNumRightSpots());
          } else {
            numSpotsDiff = Math.abs(encA.getNumSpots() - encB.getNumSpots());
          }
          boostString = boostString + ", " + Integer.toString(numSpotsDiff);

          boostString = boostString + ";";

          //add to the right boosting area, left sides are used for training, right sides are used for testing
          if (swi.rightScan) {
            test.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
            test.append((boostString + "\n"));
          } else {
            train.append(("//" + encA.getEncounterNumber()) + " vs. " + encB.getEncounterNumber() + "\n");
            train.append((boostString + "\n"));
          }

          //now let's populate the reference spots

          String ref1x_A = "";
          String ref1y_A = "";
          String ref2x_A = "";
          String ref2y_A = "";
          String ref3x_A = "";
          String ref3y_A = "";
          String ref1x_B = "";
          String ref1y_B = "";
          String ref2x_B = "";
          String ref2y_B = "";
          String ref3x_B = "";
          String ref3y_B = "";

          //populate these for encA
          if (swi.rightScan) {
            if ((encA.getRightReferenceSpots() != null) && (encA.getRightReferenceSpots().size() > 0)) {

              ref1x_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidX());
              ref1y_A = Double.toString(encA.getRightReferenceSpots().get(0).getCentroidY());
              ref2x_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidX());
          }
              ref2y_A = Double.toString(encA.getRightReferenceSpots().get(1).getCentroidY());
              ref3x_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidX());
          }

              ref3y_A = Double.toString(encA.getRightReferenceSpots().get(2).getCentroidY());

            }

          } else {
            if ((encA.getLeftReferenceSpots() != null) && (encA.getLeftReferenceSpots().size() > 0)) {

              ref1x_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidX());
              ref1y_A = Double.toString(encA.getLeftReferenceSpots().get(0).getCentroidY());
              ref2x_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidX());
              ref2y_A = Double.toString(encA.getLeftReferenceSpots().get(1).getCentroidY());
              ref3x_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidX());
              ref3y_A = Double.toString(encA.getLeftReferenceSpots().get(2).getCentroidY());

            }

          }

          //populate reference spots for encB
          if (swi.rightScan) {
            if ((encB.getRightReferenceSpots() != null) && (encB.getRightReferenceSpots().size() > 0)) {

              ref1x_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidX());
              ref1y_B = Double.toString(encB.getRightReferenceSpots().get(0).getCentroidY());
              ref2x_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidX());
              ref2y_B = Double.toString(encB.getRightReferenceSpots().get(1).getCentroidY());
              ref3x_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidX());
              ref3y_B = Double.toString(encB.getRightReferenceSpots().get(2).getCentroidY());

            }

          } else {
            if ((encB.getLeftReferenceSpots() != null) && (encB.getLeftReferenceSpots().size() > 0)) {

              ref1x_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidX());
              ref1y_B = Double.toString(encB.getLeftReferenceSpots().get(0).getCentroidY());
              ref2x_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidX());
              ref2y_B = Double.toString(encB.getLeftReferenceSpots().get(1).getCentroidY());
              ref3x_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidX());
              ref3y_B = Double.toString(encB.getLeftReferenceSpots().get(2).getCentroidY());

            }

          }


          //Spot maps
          String aSpot = "false";
          String bSpot = "false";
          if (swi.rightScan) {
            try {
              if (encB.rightSpotImageFileName.endsWith("-mapped.jpg")) {
                bSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encB.getEncounterNumber());
            }
            try {
              if (encA.rightSpotImageFileName.endsWith("-mapped.jpg")) {
                aSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the rightSpotImageFileName for encounter " + encA.getEncounterNumber());
            }

          } else {
            try {
              if (encB.spotImageFileName.endsWith("-mapped.jpg")) {
                bSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the spotImageFileName for encounter " + encB.getEncounterNumber());
            }
            try {
              if (encA.spotImageFileName.endsWith("-mapped.jpg")) {
                aSpot = "true";
              }
            } catch (Exception f) {
              f.printStackTrace();
              System.out.println("I couldn't find the spotImageFileName for encounter " + encA.getEncounterNumber());
            }


          String side = "l";
          if (swi.rightScan) {
            side = "r";

        }


        //write out the Excel file
        if (!request.getParameter("number").equals("TuningTask")) {
          //finalize(workbook);
          //workbook.close();
        }

        //let's finalize the boosting files

        writeBoostFiles(train, test, request.getParameter("number"));


        myShepherd.commitDBTransaction();
        myShepherd.closeDBTransaction();

        if (request.getParameter("number").equals("TuningTask")) {
          String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=TuningTask");
          response.sendRedirect(resultsURL);
        } else {
          String resultsURL = ("http://" + CommonConfiguration.getURLLocation(request) + "/appadmin/endTuningTask.jsp?number=FalseMatchTask");
          response.sendRedirect(resultsURL);
        }

      } catch (Exception e) {
        myShepherd.rollbackDBTransaction();
        System.out.println("writeOutScanTask registered the following error...");
        e.printStackTrace();
        statusText = "failure";
      }

    }


  }
File
WriteOutScanTask.java
Developer's decision
Manual
Kind of conflict
Catch clause
Comment
For statement
If statement
Method invocation
Try statement
Variable