private void createUpdateElisaList(List<AnalysisItem> resultItems) { for (AnalysisItem resultItem : resultItems) { if (resultItem.getIsAccepted()) { List<Analysis> acceptedAnalysisList = createAnalysisFromElisaAnalysisItem(resultItem); for (Analysis analysis : acceptedAnalysisList) { analysis.setStatusId(StatusService.getInstance().getStatusID(AnalysisStatus.Finalized)); analysisUpdateList.add(analysis); } } if (resultItem.getIsRejected()) { List<Analysis> rejectedAnalysisList = createAnalysisFromElisaAnalysisItem(resultItem); for (Analysis analysis : rejectedAnalysisList) { analysis.setStatusId( StatusService.getInstance().getStatusID(AnalysisStatus.BiologistRejected)); analysisUpdateList.add(analysis); } } } }
public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { GpsImportForm gpsForm = (GpsImportForm) form; User user = (User) req.getSession().getAttribute("user"); int entryId = gpsForm.getEntryId(); String fileName = gpsForm.getFileName(); String title = gpsForm.getTitle(); String activityId = gpsForm.getActivityId(); String xml = gpsForm.getXml(); log.debug(xml); List<GpsTrack> tracks = new TcxParser().parse(xml.getBytes()); GpsTrack track = tracks.get(0); // Horrible hack. createAttachment(user, entryId, fileName, title, activityId, track); createGeotag(fileName, track); req.setAttribute("status", "success"); req.setAttribute("message", ""); log.debug("Returning status: success."); return mapping.findForward("results"); } catch (Exception e) { log.fatal("Error processing incoming Garmin XML", e); req.setAttribute("status", "failure"); req.setAttribute("message", e.toString()); return mapping.findForward("results"); } }
private void addResultSets(Analysis analysis, Result result) { Sample sample = analysis.getSampleItem().getSample(); Patient patient = sampleHumanDAO.getPatientForSample(sample); List<DocumentTrack> documents = documentTrackDAO.getByTypeRecordAndTable(RESULT_REPORT_ID, RESULT_TABLE_ID, result.getId()); if (documents.isEmpty()) { newResultSet.add(new ResultSet(result, null, null, patient, sample, null, false)); } else { modifiedResultSet.add(new ResultSet(result, null, null, patient, sample, null, false)); } }
protected TestResult getTestResult(AnalysisItem analysisItem) { TestResult testResult = null; if (ResultType.DICTIONARY.matches(analysisItem.getResultType())) { testResult = testResultDAO.getTestResultsByTestAndDictonaryResult( analysisItem.getTestId(), analysisItem.getResult()); } else { List<TestResult> testResultList = testResultDAO.getTestResultsByTest(analysisItem.getTestId()); // we are assuming there is only one testResult for a numeric type // result if (!testResultList.isEmpty()) { testResult = testResultList.get(0); } } return testResult; }
public void validateQuantifiableItems(AnalysisItem analysisItem, List<ActionError> errors) { if (analysisItem.isHasQualifiedResult() && isBlankOrNull(analysisItem.getQualifiedResultValue()) && analysisItemWillBeUpdated(analysisItem)) { errors.add(new ActionError("errors.missing.result.details", new StringBuilder("Result"))); } // verify that qualifiedResultValue has been entered if required if (!isBlankOrNull(analysisItem.getQualifiedDictionaryId())) { String[] qualifiedDictionaryIds = analysisItem.getQualifiedDictionaryId().replace("[", "").replace("]", "").split(","); Set<String> qualifiedDictIdsSet = new HashSet<String>(Arrays.asList(qualifiedDictionaryIds)); if (qualifiedDictIdsSet.contains(analysisItem.getResult()) && isBlankOrNull(analysisItem.getQualifiedResultValue())) { errors.add(new ActionError("errors.missing.result.details", new StringBuilder("Result"))); } } }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @exception Exception if business logic throws an exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need MessageResources messages = getResources(request); // save errors ActionMessages errors = new ActionMessages(); // START check for login (security) if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) { return (mapping.findForward("welcome")); } // END check for login (security) // get the current user for displaying personal info, such as "My Projects" User u = UserService.getInstance() .getSingleUser((String) request.getSession(false).getAttribute("username")); System.out.println( "local addresss sssssssssssssss" + request.getLocalAddr() + " " + request.getLocalName()); long startProjects = System.currentTimeMillis(); String myName = u.getFirstName() + " " + u.getLastName(); List myHr = HrHelper.getAllEmployeesFormer(u); long endProjects = System.currentTimeMillis(); System.out.println("GetMyHrAction took:" + ((endProjects - startProjects) / 1000.0)); response.setContentType("text/html"); response.setHeader("Cache-Control", "no-cache"); // System.out.println(actResponse.toXML()); PrintWriter out = response.getWriter(); out.println(new JSONArray(myHr.toArray())); out.flush(); // Forward control to the specified success URI return (null); }
private ActionMessages validateModifiedItems(List<AnalysisItem> resultItemList) { ActionErrors errors = new ActionErrors(); for (AnalysisItem item : resultItemList) { List<ActionError> errorList = new ArrayList<ActionError>(); validateQuantifiableItems(item, errorList); if (errorList.size() > 0) { StringBuilder augmentedAccession = new StringBuilder(item.getAccessionNumber()); augmentedAccession.append(" : "); augmentedAccession.append(item.getTestName()); ActionError accessionError = new ActionError("errors.followingAccession", augmentedAccession); errors.add(ActionErrors.GLOBAL_MESSAGE, accessionError); for (ActionError error : errorList) { errors.add(ActionErrors.GLOBAL_MESSAGE, error); } } } return errors; }
/** * Creates a GPX-formatted file attachment for the given entry. * * @param user * @param entryId * @param fileName * @param activityId * @param track * @param track */ public void createAttachment( User user, int entryId, String fileName, String title, String activityId, GpsTrack track) throws DataAccessException, IOException { Attachment a = new Attachment(); a.setUserName(user.getUserName()); a.setUserId(user.getUserId()); a.setEntryId(entryId); a.setFileType("map"); a.setFileName(fileName); a.setActivityId(activityId); a.setTitle(title); GpxFormatter formatter = new GpxFormatter(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); List<GpsTrack> tracks = new ArrayList<GpsTrack>(); tracks.add(track); formatter.format(tracks, baos); log.debug(new String(baos.toByteArray())); a.setBytes(baos.toByteArray()); new AttachmentDao().create(a); }
private void createUpdateList(List<AnalysisItem> analysisItems, boolean areListeners) { List<String> analysisIdList = new ArrayList<String>(); for (AnalysisItem analysisItem : analysisItems) { if (!analysisItem.isReadOnly() && analysisItemWillBeUpdated(analysisItem)) { AnalysisService analysisService = new AnalysisService(analysisItem.getAnalysisId()); Analysis analysis = analysisService.getAnalysis(); NoteService noteService = new NoteService(analysis); analysis.setSysUserId(currentUserId); if (!analysisIdList.contains(analysis.getId())) { if (analysisItem.getIsAccepted()) { analysis.setStatusId(StatusService.getInstance().getStatusID(AnalysisStatus.Finalized)); analysis.setReleasedDate(new java.sql.Date(Calendar.getInstance().getTimeInMillis())); analysisIdList.add(analysis.getId()); analysisUpdateList.add(analysis); } if (analysisItem.getIsRejected()) { analysis.setStatusId( StatusService.getInstance().getStatusID(AnalysisStatus.BiologistRejected)); analysisIdList.add(analysis.getId()); analysisUpdateList.add(analysis); } } createNeededNotes(analysisItem, noteService); if (areResults(analysisItem)) { List<Result> results = createResultFromAnalysisItem(analysisItem, analysisService, noteService); for (Result result : results) { resultUpdateList.add(result); if (areListeners) { addResultSets(analysis, result); } } } } } }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @exception Exception if business logic throws an exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need MessageResources messages = getResources(request); // save errors ActionMessages errors = new ActionMessages(); // START check for login (security) if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) { return (mapping.findForward("welcome")); } // END check for login (security) // START get id of current project from either request, attribute, or cookie // id of project from request String projectId = null; projectId = request.getParameter("projectViewId"); // check attribute in request if (projectId == null) { projectId = (String) request.getAttribute("projectViewId"); } // id of project from cookie if (projectId == null) { projectId = StandardCode.getInstance().getCookie("projectViewId", request.getCookies()); } // default project to last if not in request or cookie if (projectId == null) { List results = ProjectService.getInstance().getProjectList(); ListIterator iterScroll = null; for (iterScroll = results.listIterator(); iterScroll.hasNext(); iterScroll.next()) {} iterScroll.previous(); Project p = (Project) iterScroll.next(); projectId = String.valueOf(p.getProjectId()); } Integer id = Integer.valueOf(projectId); // END get id of current project from either request, attribute, or cookie // get project to edit Project p = ProjectService.getInstance().getSingleProject(id); // get this project's sources Set sources = p.getSourceDocs(); // for each source add each sources' Tasks List totalLinTasks = new ArrayList(); // for each source for (Iterator sourceIter = sources.iterator(); sourceIter.hasNext(); ) { SourceDoc sd = (SourceDoc) sourceIter.next(); // for each target of this source for (Iterator linTargetIter = sd.getTargetDocs().iterator(); linTargetIter.hasNext(); ) { TargetDoc td = (TargetDoc) linTargetIter.next(); // for each lin Task of this target for (Iterator linTaskIter = td.getLinTasks().iterator(); linTaskIter.hasNext(); ) { LinTask lt = (LinTask) linTaskIter.next(); if (lt.getPersonName() != null && lt.getDueDateDate() != null && (lt.getTaskName().equalsIgnoreCase("Translation") || lt.getTaskName().equalsIgnoreCase("Editing") || lt.getTaskName().trim().equalsIgnoreCase("Proofreading") || lt.getTaskName().equalsIgnoreCase("Proofreading / Linguistic QA"))) { totalLinTasks.add(lt); } System.out.println( sd.getLanguage() + "--------" + td.getLanguage() + "---------" + lt.getTaskName()); } } } // Sort by task (orderNum), then source (language), then target (language) Collections.sort(totalLinTasks, CompareTaskLin.getInstance()); Collections.sort(totalLinTasks, CompareTaskLanguages.getInstance()); // array for display in jsp LinTask[] linTasksArray = (LinTask[]) totalLinTasks.toArray(new LinTask[0]); for (int i = 0; i < totalLinTasks.size(); i++) { request.setAttribute(projectId, log); } // place all Tasks for this project into the form for display DynaValidatorForm qvg = (DynaValidatorForm) form; // HERE down is standard and does not need to change when adding task blocks // place this project into request for further display in jsp page request.setAttribute("project", p); // add this project id to cookies; this will remember the last project response.addCookie(StandardCode.getInstance().setCookie("projectViewId", projectId)); // add tab location to cookies; this will remember which tab we are at response.addCookie(StandardCode.getInstance().setCookie("projectViewTab", "Team")); // an update of totals may be required // Forward control to the specified success URI return (mapping.findForward("Success")); }
private List<Analysis> createAnalysisFromElisaAnalysisItem(AnalysisItem analysisItem) { List<Analysis> analysisList = new ArrayList<Analysis>(); Analysis analysis = new Analysis(); if (!isBlankOrNull(analysisItem.getMurexResult())) { analysis = getAnalysisFromId(analysisItem.getMurexAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getBiolineResult())) { analysis = getAnalysisFromId(analysisItem.getBiolineAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getIntegralResult())) { analysis = getAnalysisFromId(analysisItem.getIntegralAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getVironostikaResult())) { analysis = getAnalysisFromId(analysisItem.getVironostikaAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getGenieIIResult())) { analysis = getAnalysisFromId(analysisItem.getGenieIIAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getGenieII10Result())) { analysis = getAnalysisFromId(analysisItem.getGenieII10AnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getGenieII100Result())) { analysis = getAnalysisFromId(analysisItem.getGenieII100AnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getWesternBlot1Result())) { analysis = getAnalysisFromId(analysisItem.getWesternBlot1AnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getWesternBlot2Result())) { analysis = getAnalysisFromId(analysisItem.getWesternBlot2AnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getP24AgResult())) { analysis = getAnalysisFromId(analysisItem.getP24AgAnalysisId()); analysisList.add(analysis); } if (!isBlankOrNull(analysisItem.getInnoliaResult())) { analysis = getAnalysisFromId(analysisItem.getInnoliaAnalysisId()); analysisList.add(analysis); } analysisList.add(analysis); return analysisList; }
@Override protected ActionForward performAction( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward = FWD_SUCCESS; List<IResultUpdate> updaters = ValidationUpdateRegister.getRegisteredUpdaters(); boolean areListeners = updaters != null && !updaters.isEmpty(); request.getSession().setAttribute(SAVE_DISABLED, "true"); BaseActionForm dynaForm = (BaseActionForm) form; ResultValidationPaging paging = new ResultValidationPaging(); paging.updatePagedResults(request, dynaForm); List<AnalysisItem> resultItemList = paging.getResults(request); String testSectionName = (String) dynaForm.get("testSection"); String testName = (String) dynaForm.get("testName"); setRequestType(testSectionName); ActionMessages errors = validateModifiedItems(resultItemList); if (errors.size() > 0) { saveErrors(request, errors); request.setAttribute(Globals.ERROR_KEY, errors); return mapping.findForward(FWD_VALIDATION_ERROR); } createSystemUser(); setSampleFinishedStatuses(); noteUpdateList = new ArrayList<Note>(); resultUpdateList = new ArrayList<Result>(); analysisUpdateList = new ArrayList<Analysis>(); modifiedResultSet = new ArrayList<ResultSet>(); newResultSet = new ArrayList<ResultSet>(); deletableList = new ArrayList<Result>(); if (testSectionName.equals("serology")) { createUpdateElisaList(resultItemList); } else { createUpdateList(resultItemList, areListeners); } Transaction tx = HibernateUtil.getSession().beginTransaction(); try { ResultSaveService.removeDeletedResultsInTransaction(deletableList, currentUserId); // update analysis for (Analysis analysis : analysisUpdateList) { analysisDAO.updateData(analysis); } for (Result result : resultUpdateList) { if (result.getId() != null) { resultDAO.updateData(result); } else { resultDAO.insertData(result); } } checkIfSamplesFinished(resultItemList); // update finished samples for (Sample sample : sampleUpdateList) { sampleDAO.updateData(sample); } // create or update notes for (Note note : noteUpdateList) { if (note != null) { if (note.getId() == null) { noteDAO.insertData(note); } else { noteDAO.updateData(note); } } } for (IResultUpdate updater : updaters) { updater.transactionalUpdate(this); } tx.commit(); } catch (LIMSRuntimeException lre) { tx.rollback(); } for (IResultUpdate updater : updaters) { updater.postTransactionalCommitUpdate(this); } if (isBlankOrNull(testSectionName)) { return mapping.findForward(forward); } else { Map<String, String> params = new HashMap<String, String>(); params.put("type", testSectionName); params.put("test", testName); params.put("forward", forward); return getForwardWithParameters(mapping.findForward(forward), params); } }
/** * Process the specified HTTP request, and create the corresponding HTTP response (or forward to * another web component that will create it). Return an <code>ActionForward</code> instance * describing where and how control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param form The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * @exception Exception if business logic throws an exception */ public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // Extract attributes we will need MessageResources messages = getResources(request); // save errors ActionMessages errors = new ActionMessages(); // START check for login (security) if (!SecurityService.getInstance().checkForLogin(request.getSession(false))) { return (mapping.findForward("welcome")); } // END check for login (security) // START get id of current quote from either request, attribute, or cookie // id of quote from request String projectId = null; projectId = request.getParameter("projectViewId"); // check attribute in request if (projectId == null) { projectId = (String) request.getAttribute("projectViewId"); } // id of quote from cookie if (projectId == null) { projectId = StandardCode.getInstance().getCookie("projectViewId", request.getCookies()); } // default client to first if not in request or cookie if (projectId == null) { List results = QuoteService.getInstance().getQuoteList(); Quote1 first = (Quote1) results.get(0); projectId = String.valueOf(first.getQuote1Id()); } // projectId="6553"; Integer id = Integer.valueOf(projectId); String[] dataValue = new String[11]; Project p = ProjectService.getInstance().getSingleProject(Integer.parseInt(projectId)); // END get id of current quote from either request, attribute, or cookie // get quote to add files to // Quote1 q = QuoteService.getInstance().getSingleQuote(p.getQuotes()); Set sources = p.getSourceDocs(); // get the lin task to update // String linTaskId = StandardCode.getInstance().getCookie("quoteViewGeneralTradosUploadId", // request.getCookies()); System.out.println(sources.size()); File folder = new File("C:/log"); File[] listOfFiles = folder.listFiles(); for (int ij = 0; ij < listOfFiles.length; ij++) { if (listOfFiles[ij].isFile() && (listOfFiles[ij].getName().endsWith(".log")) || listOfFiles[ij].getName().endsWith(".xls") || listOfFiles[ij].getName().endsWith(".xlsx") || listOfFiles[ij].getName().endsWith(".xml")) { String lang = ""; System.out.println("File " + listOfFiles[ij].getName()); String myFile = listOfFiles[ij].getName(); Integer leng = myFile.length(); if (listOfFiles[ij].getName().endsWith(".log")) { lang = (String) LanguageAbs.getInstance().getAbs().get(myFile.substring(leng - 6, leng - 4)); } else if (listOfFiles[ij].getName().endsWith(".xlsx")) { lang = (String) LanguageAbs.getInstance().getAbs().get(myFile.substring(leng - 7, leng - 5)); } else { lang = (String) LanguageAbs.getInstance().getAbs().get(myFile.substring(leng - 6, leng - 4)); } // List sourceLang = QuoteService.getInstance().getSourceLang1(q); for (Iterator sourceIter = sources.iterator(); sourceIter.hasNext(); ) { SourceDoc sd = (SourceDoc) sourceIter.next(); List targetLang = QuoteService.getInstance().getTargetLang(sd.getSourceDocId()); for (Iterator linTargetIter = sd.getTargetDocs().iterator(); linTargetIter.hasNext(); ) { TargetDoc td = (TargetDoc) linTargetIter.next(); if (td.getLanguage().equalsIgnoreCase(lang)) { List linTasklist = QuoteService.getInstance().getLinTask(td.getTargetDocId()); for (int k = 0; k < linTasklist.size(); k++) { LinTask lt = (LinTask) linTasklist.get(k); // get input stream // InputStream in = listOfFiles[ij].getInputStream(); if (listOfFiles[ij].getName().endsWith(".log")) { FileInputStream in = new FileInputStream(listOfFiles[ij]); // byte[] fileData = listOfFiles[ij].getFileData(); //byte array of entire file long length = listOfFiles[ij].length(); byte[] fileData = new byte[(int) length]; in.read(fileData); // read data into fileData String entireRead = new String(fileData); // the entire file as a string String[] lines = entireRead.split("\n"); // lines within the file String line = new String(""); // each line // scroll to totals int j = 0; // line numbers try { while (true) { line = lines[j++]; if (line != null && line.length() > 12 && line.substring(0, 13).equals("Analyse Total")) { break; } } // move to repetitions line j++; j++; j++; String[] parts; // each number per line String wordRep = null; String word100 = null; String word95 = null; String word85 = null; String word75 = null; String word50 = null; String wordNo = null; String wordPerfect = null; String wordContext = null; String wordTotal = null; // wordRep line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 3) { // if at the words column wordRep = parts[i]; break; } } // word100 line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 3) { // if at the words column word100 = parts[i]; break; } } // word95 line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 5) { // if at the words column word95 = parts[i]; break; } } // word85 line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 5) { // if at the words column word85 = parts[i]; break; } } // word75 line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 5) { // if at the words column word75 = parts[i]; break; } } // word50 line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 5) { // if at the words column word50 = parts[i]; break; } } // wordNo line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 4) { // if at the words column wordNo = parts[i]; break; } } // wordTotal line = lines[j++]; parts = line.split(" "); for (int i = 0, counter = 0; i < parts.length; i++) { if (parts[i].length() > 0) { // look for non-blank items and count them counter++; } if (counter == 3) { // if at the words column wordTotal = parts[i]; break; } } // END process the trados .log file // remove commas from trados values wordRep = wordRep.replaceAll(",", ""); word100 = word100.replaceAll(",", ""); word95 = word95.replaceAll(",", ""); word85 = word85.replaceAll(",", ""); word75 = word75.replaceAll(",", ""); word50 = word50.replaceAll(",", ""); wordNo = wordNo.replaceAll(",", ""); // wordPerfect=null; // wordContext=null; wordTotal = wordTotal.replaceAll(",", ""); // convert trados values from strings to numbers Integer numRep = Integer.valueOf(wordRep); Integer num100 = Integer.valueOf(word100); Integer num95 = Integer.valueOf(word95); Integer num85 = Integer.valueOf(word85); Integer num75 = Integer.valueOf(word75); Integer num50 = Integer.valueOf(word50); Integer numNo = Integer.valueOf(wordNo); Double numTotal = Double.valueOf(wordTotal); // find totals to save to lin task int numNew = num50.intValue() + numNo.intValue(); int num8599 = num95.intValue() + num85.intValue(); int numNew4 = num75.intValue() + numNew; if (lt.getTaskName().equalsIgnoreCase("Translation")) { // set new trados values for the lin task lt.setWordRep(numRep); lt.setWord100(num100); lt.setWord95(num95); lt.setWord85(num85); lt.setWord75(num75); lt.setWordNew(new Integer(numNew)); lt.setWord8599(new Integer(num8599)); lt.setWordNew4(new Double(numNew4)); lt.setWordTotal(numTotal); } else if (lt.getTaskName().equalsIgnoreCase("editing")) { lt.setWordNew4(numTotal); lt.setWordTotal(numTotal); } // upload the new trados values to db ProjectService.getInstance().updateLinTask(lt); // START get file list // get input stream in.close(); in = new FileInputStream(listOfFiles[ij]); length = listOfFiles[ij].length(); fileData = new byte[(int) length]; in.read(fileData); // read data into fileData entireRead = new String(fileData); // the entire file as a string lines = entireRead.split("\n"); // lines within the file line = new String(""); // each line } catch (Exception e) { } in.close(); } else if (listOfFiles[ij].isFile() && listOfFiles[ij].getName().endsWith(".xls")) { POIFSFileSystem fs = new POIFSFileSystem( new FileInputStream("C:/log/" + listOfFiles[ij].getName())); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); HSSFRow row; HSSFCell cell; int count = 0, i = 0; String flag = "true"; Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { row = (HSSFRow) rows.next(); count = 0; Iterator cells = row.cellIterator(); while (cells.hasNext()) { cell = (HSSFCell) cells.next(); count++; try { if (count == 4 && flag.equalsIgnoreCase("true")) { dataValue[i++] = cell.toString(); System.out.println("cel value----------> " + cell.toString()); if (i > 10) { flag = "false"; } } } catch (Exception e) { System.out.println("Integer Value" + count++); } } } Integer numRep = Math.round(Float.parseFloat(dataValue[2])); Integer num100 = Math.round(Float.parseFloat(dataValue[4])); Integer num95 = Math.round(Float.parseFloat(dataValue[5])); Integer num85 = Math.round(Float.parseFloat(dataValue[6])); Integer num75 = Math.round(Float.parseFloat(dataValue[7])); Integer num50 = Math.round(Float.parseFloat(dataValue[8])); Integer numNo = Math.round(Float.parseFloat(dataValue[9])); Integer numPerfect = Math.round(Float.parseFloat(dataValue[1])); Integer numContext = Math.round(Float.parseFloat(dataValue[3])); Double numTotal = Double.valueOf(dataValue[10]); // numRep = Integer.parseInt(dataValue[1]); int numNew = num50.intValue() + numNo.intValue(); int num8599 = num95.intValue() + num85.intValue(); int numNew4 = num75.intValue() + numNew; if (lt.getTaskName().equalsIgnoreCase("Translation")) { // set new trados values for the lin task lt.setWordRep(numRep); lt.setWord100(num100); lt.setWord95(num95); lt.setWord85(num85); lt.setWord75(num75); lt.setWordNew(new Integer(numNew)); lt.setWord8599(new Integer(num8599)); lt.setWordNew4(new Double(numNew4)); lt.setWordContext(numContext); lt.setWordPerfect(numPerfect); lt.setWordTotal(numTotal); } else if (lt.getTaskName().equalsIgnoreCase("editing")) { lt.setWordNew4(numTotal); lt.setWordTotal(numTotal); } // upload the new trados values to db ProjectService.getInstance().updateLinTask(lt); } else if (listOfFiles[ij].isFile() && listOfFiles[ij].getName().endsWith(".xlsx")) { // POIFSFileSystem fs = new // POIFSFileSystem(new FileInputStream("C:/log/" + listOfFiles[ij].getName())); // File file = new File("C:/log/" + // listOfFiles[ij].getName()); // OPCPackage pkg = OPCPackage.open(new // FileInputStream(file.getAbsolutePath())); // XSSFWorkbook wb = new XSSFWorkbook(pkg); InputStream fs = new FileInputStream("C:/log/" + listOfFiles[ij].getName()); XSSFWorkbook wb = new XSSFWorkbook(fs); // XSSFWorkbook wb = new XSSFWorkbook(fs); XSSFSheet sheet = wb.getSheetAt(0); XSSFRow row; XSSFCell cell; int count = 0, i = 0; String flag = "true"; Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { row = (XSSFRow) rows.next(); count = 0; Iterator cells = row.cellIterator(); while (cells.hasNext()) { cell = (XSSFCell) cells.next(); count++; try { if (count == 4 && flag.equalsIgnoreCase("true")) { dataValue[i++] = cell.toString(); System.out.println("cel value----------> " + cell.toString()); if (i > 10) { flag = "false"; } } } catch (Exception e) { System.out.println("Integer Value" + count++); } } } Integer numRep = Math.round(Float.parseFloat(dataValue[2])); Integer num100 = Math.round(Float.parseFloat(dataValue[4])); Integer num95 = Math.round(Float.parseFloat(dataValue[5])); Integer num85 = Math.round(Float.parseFloat(dataValue[6])); Integer num75 = Math.round(Float.parseFloat(dataValue[7])); Integer num50 = Math.round(Float.parseFloat(dataValue[8])); Integer numNo = Math.round(Float.parseFloat(dataValue[9])); Double numTotal = Double.valueOf(dataValue[10]); // numRep = Integer.parseInt(dataValue[1]); int numNew = num50.intValue() + numNo.intValue(); int num8599 = num95.intValue() + num85.intValue(); int numNew4 = num75.intValue() + numNew; if (lt.getTaskName().equalsIgnoreCase("Translation")) { // set new trados values for the lin task lt.setWordRep(numRep); lt.setWord100(num100); lt.setWord95(num95); lt.setWord85(num85); lt.setWord75(num75); lt.setWordNew(new Integer(numNew)); lt.setWord8599(new Integer(num8599)); lt.setWordNew4(new Double(numNew4)); lt.setWordTotal(numTotal); } else if (lt.getTaskName().equalsIgnoreCase("editing")) { lt.setWordNew4(numTotal); lt.setWordTotal(numTotal); } // upload the new trados values to db ProjectService.getInstance().updateLinTask(lt); } else if (listOfFiles[ij].isFile() && listOfFiles[ij].getName().endsWith(".xml")) { InputStream in = new FileInputStream("C:/log/" + listOfFiles[ij].getName()); System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(in); doc.getDocumentElement().normalize(); System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); Integer numRep = 0; Integer num100 = 0; Integer num95 = 0; Integer num85 = 0; Integer num75 = 0; Integer num50 = 0; Integer numNo = 0; Integer numTotal = 0; Integer numContext = 0; Integer numPerfect = 0; NodeList batchTotal = doc.getElementsByTagName("batchTotal"); // Element eElement = (Element) batchTotal; // NodeList analyse = // eElement.getElementsByTagName("analyse"); if (batchTotal != null && batchTotal.getLength() > 0) { Node node = batchTotal.item(0); if (node.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) node; NodeList analyse = eElement.getElementsByTagName("analyse"); if (analyse != null && analyse.getLength() > 0) { Node node1 = analyse.item(0); if (node1.getNodeType() == Node.ELEMENT_NODE) { Element eElement1 = (Element) node1; // NodeList analyse1 = // eElement.getElementsByTagName("analyse"); eElement1.getElementsByTagName("fuzzy").item(0).getTextContent(); NodeList fuzzy = doc.getElementsByTagName("fuzzy"); for (int temp = 0; temp < fuzzy.getLength(); temp++) { Node nNode = fuzzy.item(temp); System.out.println("\nCurrent Element :" + nNode.getNodeName()); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; if (eElement2.getAttribute("min").equalsIgnoreCase("50") && eElement2.getAttribute("max").equalsIgnoreCase("74")) { num50 = Integer.parseInt(eElement2.getAttribute("words")); } if (eElement2.getAttribute("min").equalsIgnoreCase("75") && eElement2.getAttribute("max").equalsIgnoreCase("84")) { num75 = Integer.parseInt(eElement2.getAttribute("words")); } if (eElement2.getAttribute("min").equalsIgnoreCase("85") && eElement2.getAttribute("max").equalsIgnoreCase("94")) { num85 = Integer.parseInt(eElement2.getAttribute("words")); } if (eElement2.getAttribute("min").equalsIgnoreCase("95") && eElement2.getAttribute("max").equalsIgnoreCase("99")) { num95 = Integer.parseInt(eElement2.getAttribute("words")); } } } // eElement1.getElementsByTagName("new").item(0).getTextContent(); NodeList new1 = doc.getElementsByTagName("new"); for (int temp = 0; temp < new1.getLength(); temp++) { Node nNode = new1.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numNo = Integer.parseInt(eElement2.getAttribute("words")); } } eElement1.getElementsByTagName("total").item(0).getTextContent(); NodeList total = doc.getElementsByTagName("total"); for (int temp = 0; temp < total.getLength(); temp++) { Node nNode = total.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numTotal = Integer.parseInt(eElement2.getAttribute("words")); } } eElement1.getElementsByTagName("exact").item(0).getTextContent(); NodeList exact = doc.getElementsByTagName("exact"); for (int temp = 0; temp < exact.getLength(); temp++) { Node nNode = exact.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; num100 = Integer.parseInt(eElement2.getAttribute("words")); } } eElement1.getElementsByTagName("perfect").item(0).getTextContent(); NodeList perfect = doc.getElementsByTagName("perfect"); for (int temp = 0; temp < perfect.getLength(); temp++) { Node nNode = perfect.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numPerfect = Integer.parseInt(eElement2.getAttribute("words")); } } eElement1.getElementsByTagName("repeated").item(0).getTextContent(); NodeList repeated = doc.getElementsByTagName("repeated"); for (int temp = 0; temp < repeated.getLength(); temp++) { Node nNode = repeated.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numRep = Integer.parseInt(eElement2.getAttribute("words")); } } try { eElement1 .getElementsByTagName("crossFileRepeated") .item(0) .getTextContent(); NodeList crossFileRepeated = doc.getElementsByTagName("crossFileRepeated"); for (int temp = 0; temp < crossFileRepeated.getLength(); temp++) { Node nNode = crossFileRepeated.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numRep += Integer.parseInt(eElement2.getAttribute("words")); } } } catch (Exception e) { } eElement1.getElementsByTagName("inContextExact").item(0).getTextContent(); NodeList inContextExact = doc.getElementsByTagName("inContextExact"); for (int temp = 0; temp < inContextExact.getLength(); temp++) { Node nNode = inContextExact.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement2 = (Element) nNode; numContext = Integer.parseInt(eElement2.getAttribute("words")); } } } } } } int numNew = num50.intValue() + numNo.intValue(); int num8599 = num95.intValue() + num85.intValue(); int numNew4 = num75.intValue() + numNew; if (lt.getTaskName().equalsIgnoreCase("Translation")) { // set new trados values for the lin task lt.setWordRep(numRep); lt.setWord100(num100); lt.setWord95(num95); lt.setWord85(num85); lt.setWord75(num75); lt.setWordNew(new Integer(numNew)); lt.setWord8599(new Integer(num8599)); lt.setWordNew4(new Double(numNew4)); lt.setWordTotal(new Double(numTotal)); lt.setWordContext(numContext); lt.setWordPerfect(numPerfect); } else if (lt.getTaskName().equalsIgnoreCase("editing")) { lt.setWordNew(new Integer(numTotal)); lt.setWordNew4(new Double(numTotal)); lt.setWordTotal(new Double(numTotal)); } // upload the new trados values to db ProjectService.getInstance().updateLinTask(lt); } else { System.out.println("no Match"); request.setAttribute("isError", "error"); return (mapping.findForward("Error")); } } } } } } else if (listOfFiles[ij].isDirectory()) { System.out.println("Directory " + listOfFiles[ij].getName()); } } deleteFile("C:/log"); // END get file list // Forward control to the specified success URI return (mapping.findForward("Success")); }