private Path holePathVonNeuemLaufwerk(ArrayList<Path> initial, ArrayList<Path> aktuell) { ArrayList<Path> test, test1; test = (ArrayList<Path>) aktuell.clone(); test1 = (ArrayList<Path>) initial.clone(); test.removeAll(test1); return test.get(test.size() - 1); }
/** * Check if components required by specified products are available. * * @param products list of ProdOrderProductVO objects * @params compAltComps collection of <component item code,HashSet of alternative component item * codes>; filled by this method (and given back by reference) * @return VOListResponse of ProdOrderComponentVO objects */ public final Response checkComponentsAvailability( Connection conn, Hashtable compAltComps, ArrayList products, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { String serverLanguageId = ((JAIOUserSessionParameters) userSessionPars).getServerLanguageId(); try { // retrieve internationalization settings (Resources object)... ServerResourcesFactory factory = (ServerResourcesFactory) context.getAttribute(Controller.RESOURCES_FACTORY); Resources resources = factory.getResources(userSessionPars.getLanguageId()); if (products.size() == 0) { return new VOListResponse(new ArrayList(), false, 0); } // fill in comps hashtable with the collection of required components... ItemPK pk = null; ProdOrderProductVO prodVO = null; ArrayList components = null; MaterialVO compVO = null; Response res = null; ProdOrderComponentVO componentVO = null; Hashtable comps = new Hashtable(); // collection of <component item code,ProdOrderComponentVO object> for (int i = 0; i < products.size(); i++) { // retrieve bill of materials for each product... prodVO = (ProdOrderProductVO) products.get(i); pk = new ItemPK(prodVO.getCompanyCodeSys01DOC23(), prodVO.getItemCodeItm01DOC23()); res = bean.getBillOfMaterials( conn, pk, userSessionPars, request, response, userSession, context); if (res.isError()) { return res; } // extract components only (leaf nodes)... components = getComponents( (DefaultMutableTreeNode) ((TreeModel) ((VOResponse) res).getVo()).getRoot()); for (int j = 0; j < components.size(); j++) { compVO = (MaterialVO) components.get(j); componentVO = (ProdOrderComponentVO) comps.get(compVO.getItemCodeItm01ITM03()); if (componentVO == null) { componentVO = new ProdOrderComponentVO(); comps.put(compVO.getItemCodeItm01ITM03(), componentVO); componentVO.setAvailableQty(new BigDecimal(0)); componentVO.setCompanyCodeSys01DOC24(compVO.getCompanyCodeSys01ITM03()); componentVO.setDescriptionSYS10(compVO.getDescriptionSYS10()); componentVO.setDocNumberDOC24(prodVO.getDocNumberDOC23()); componentVO.setDocYearDOC24(prodVO.getDocYearDOC23()); componentVO.setItemCodeItm01DOC24(compVO.getItemCodeItm01ITM03()); componentVO.setMinSellingQtyUmCodeReg02ITM01(compVO.getMinSellingQtyUmCodeReg02ITM01()); componentVO.setQtyDOC24(new BigDecimal(0)); } componentVO.setQtyDOC24( componentVO.getQtyDOC24().add(compVO.getQtyITM03().multiply(prodVO.getQtyDOC23()))); } } // check components availability in the specified warehouse... Enumeration en = comps.keys(); GridParams gridParams = new GridParams(); gridParams .getOtherGridParams() .put(ApplicationConsts.COMPANY_CODE_SYS01, prodVO.getCompanyCodeSys01DOC23()); gridParams .getOtherGridParams() .put(ApplicationConsts.WAREHOUSE_CODE, prodVO.getWarehouseCodeWar01DOC22()); gridParams.getOtherGridParams().put(ApplicationConsts.LOAD_ALL, Boolean.TRUE); ItemAvailabilityVO availVO = null; BigDecimal availability, altAvailability, delta; String itemCode = null; ArrayList list, availList; AltComponentVO altVO = null; ArrayList alternativeComps = new ArrayList(); ArrayList compsToRemove = new ArrayList(); ProdOrderComponentVO altComponentVO = null; HashSet altCodes = null; // list of alternative component item codes... BigDecimal altQty = null; while (en.hasMoreElements()) { itemCode = en.nextElement().toString(); componentVO = (ProdOrderComponentVO) comps.get(itemCode); gridParams .getOtherGridParams() .put( ApplicationConsts.ITEM_PK, new ItemPK(prodVO.getCompanyCodeSys01DOC23(), itemCode)); res = avail.executeCommand( gridParams, userSessionPars, request, response, userSession, context); if (res.isError()) return res; availList = ((VOListResponse) res).getRows(); componentVO.setAvailabilities(availList); availability = new BigDecimal(0); for (int i = 0; i < availList.size(); i++) { availVO = (ItemAvailabilityVO) availList.get(i); availability = availability.add(availVO.getAvailableQtyWAR03()); } componentVO.setAvailableQty(availability); if (componentVO.getQtyDOC24().doubleValue() > componentVO.getAvailableQty().doubleValue()) { // check if there exist some alternative component... res = altComps.executeCommand( gridParams, userSessionPars, request, response, userSession, context); if (res.isError()) return res; list = ((VOListResponse) res).getRows(); for (int i = 0; i < list.size(); i++) { altVO = (AltComponentVO) list.get(i); gridParams .getOtherGridParams() .put( ApplicationConsts.ITEM_PK, new ItemPK(prodVO.getCompanyCodeSys01DOC23(), altVO.getItemCodeItm01ITM04())); res = avail.executeCommand( gridParams, userSessionPars, request, response, userSession, context); if (res.isError()) return res; availList = ((VOListResponse) res).getRows(); altAvailability = new BigDecimal(0); for (int j = 0; j < availList.size(); j++) { availVO = (ItemAvailabilityVO) availList.get(j); altAvailability = altAvailability.add(availVO.getAvailableQtyWAR03()); } if (altAvailability.doubleValue() > 0) { altComponentVO = new ProdOrderComponentVO(); altComponentVO.setAvailabilities(availList); altComponentVO.setAvailableQty(altAvailability); altComponentVO.setCompanyCodeSys01DOC24(altVO.getCompanyCodeSys01ITM04()); altComponentVO.setDescriptionSYS10(altVO.getDescriptionSYS10()); altComponentVO.setDocNumberDOC24(prodVO.getDocNumberDOC23()); altComponentVO.setDocYearDOC24(prodVO.getDocYearDOC23()); altComponentVO.setItemCodeItm01DOC24(altVO.getItemCodeItm01ITM04()); altComponentVO.setMinSellingQtyUmCodeReg02ITM01( altVO.getMinSellingQtyUmCodeReg02ITM01()); altQty = conv.convertQty( altVO.getMinSellingQtyUmCodeReg02ITM01(), componentVO.getMinSellingQtyUmCodeReg02ITM01(), altAvailability, userSessionPars, request, response, userSession, context); if (componentVO.getQtyDOC24().subtract(availability).doubleValue() > altQty.doubleValue()) { delta = altQty; altComponentVO.setQtyDOC24(altAvailability); } else { delta = componentVO.getQtyDOC24(); altComponentVO.setQtyDOC24( conv.convertQty( componentVO.getMinSellingQtyUmCodeReg02ITM01(), altVO.getMinSellingQtyUmCodeReg02ITM01(), delta, userSessionPars, request, response, userSession, context)); } componentVO.setQtyDOC24(componentVO.getQtyDOC24().subtract(delta)); alternativeComps.add(altComponentVO); altCodes = (HashSet) compAltComps.get(itemCode); if (altCodes == null) { altCodes = new HashSet(); compAltComps.put(itemCode, altCodes); } altCodes.add(altVO.getItemCodeItm01ITM04()); if (componentVO.getQtyDOC24().doubleValue() == 0) { compsToRemove.add(componentVO); break; } if (componentVO.getQtyDOC24().subtract(availability).doubleValue() == 0) break; } } } } list = new ArrayList(comps.values()); list.addAll(alternativeComps); list.removeAll(compsToRemove); return new VOListResponse(list, false, list.size()); } catch (Throwable ex) { Logger.error( userSessionPars.getUsername(), this.getClass().getName(), "checkComponentsAvailability", "Error while retrieving components availability for the specified production order", ex); return new ErrorResponse(ex.getMessage()); } }
public void CrawlRT(String RTPage) throws IOException { ArrayList<String> t = new ArrayList<String>(); String crawlData; String crawlData2; String crawlData3; FileReader freader = new FileReader("Crawl.txt"); BufferedReader br = new BufferedReader(freader); FileReader freader2 = new FileReader("Tocrawl.txt"); BufferedReader br2 = new BufferedReader(freader2); FileWriter fwriter2 = new FileWriter("Tocrawl.txt", true); BufferedWriter bw2 = new BufferedWriter(fwriter2); FileWriter fwriter = new FileWriter("Crawl.txt", true); BufferedWriter bw = new BufferedWriter(fwriter); /*while(null != (crawlData2 = br.readLine())) { if(crawlData2 !=null) Crawl.add(crawlData2); } t = collectLinks(RTPage); Iterator<String> e3= t.iterator(); while(e3.hasNext()) { String ee = e3.next(); if(!Crawl.contains(ee)) { bw2.write(ee+"\r\n"); } } br.close(); br2.close(); bw.close(); bw2.close();*/ if (null == (crawlData = br.readLine())) // if(true) { // initial iteration bw.write(RTPage + "\r\n"); Crawl.add(RTPage); t = collectLinks(RTPage); ToCrawl.addAll(t); } else { // collect data from files and load to array lists while (null != (crawlData2 = br.readLine())) { if (crawlData2 != null) Crawl.add(crawlData2); } while (null != (crawlData3 = br2.readLine())) { if (crawlData3 != null) ToCrawl.add(crawlData3); } } System.out.println("Crawlled"); // Number of movies to be crawled for (int i = 0; i < 1000; i++) { if (ToCrawl.size() > 0) { Crawl.removeAll(Collections.singleton(null)); ToCrawl.removeAll(Collections.singleton(null)); String c = ToCrawl.get(0); if (Crawl.contains(c)) ToCrawl.remove(c); else { // collect links and collect data from a particular link Crawl.add(c); t = collectLinks(c); CollectData(c); ToCrawl.remove(c); Iterator<String> e3 = t.iterator(); while (e3.hasNext()) { String ee = e3.next(); if (!ToCrawl.contains(ee)) { if (!Crawl.contains(ee)) { ToCrawl.add(ee); } } } bw.write(c + "\r\n"); } } } System.out.println("To Be Crawlled"); Iterator<String> e2 = ToCrawl.iterator(); while (e2.hasNext()) { // write to file the movies still to be crawled. bw2.write(e2.next() + "\r\n"); } prop.setProperty("Id", Integer.toString(n)); prop.store(new FileOutputStream("config.properties"), null); br.close(); br2.close(); bw.close(); bw2.close(); }
public static void main(String args[]) { double totalTime; double startTime = System.currentTimeMillis(); parseArguments(args); // preprocess input files to find the chromosomal boundaries in terms of line number /* * All files should be sorted in chromosomal order */ System.out.println("Preprocessing input files to find chromosome boundaries..."); System.out.println("\tExons file.."); ArrayList<Integer> exonFileChrBoundaries = getChromosomalBoundaries(exonFileName, 0); System.out.println("\tExpression file.."); ArrayList<Integer> exprFileChrBoundaries = getChromosomalBoundaries(expressionFileName, 2); System.out.println("\tMapped reads file.."); ArrayList<Integer> readsFileChrBoundaries = getChromosomalBoundaries(mappedReadsFileName, 2); try { BufferedReader inputExons = new BufferedReader(new FileReader(exonFileName)); BufferedReader inputExpr = new BufferedReader(new FileReader(expressionFileName)); BufferedReader inputSAMData = new BufferedReader(new FileReader(mappedReadsFileName)); for (int chromosome : chromosomes) { int arrayPosition = chromosome - chromosomes.get(0) + 1; System.out.println("Chromosome " + chromosome); System.out.println("Reading exons file...."); int numberOfLines = exonFileChrBoundaries.get(arrayPosition) - exonFileChrBoundaries.get(arrayPosition - 1); double currentTime = System.currentTimeMillis(); Exons = Exon.readExon(inputExons, chromosome, numberOfLines); double totalExonReadTime = (System.currentTimeMillis() - currentTime) / 1000F; Exon.sortExons(Exons); System.out.println("Reading expression file...."); numberOfLines = exprFileChrBoundaries.get(arrayPosition) - exprFileChrBoundaries.get(arrayPosition - 1); ArrayList<Expression> Expressions = new ArrayList<Expression>(); currentTime = System.currentTimeMillis(); Expressions = Expression.readExon(inputExpr, chromosome, numberOfLines); double totalExprReadTime = (System.currentTimeMillis() - currentTime) / 1000F; int numberOfExpr = Expressions.size(); System.out.println("Calculating FPKMs...."); currentTime = System.currentTimeMillis(); Exon.getFPKM(Expressions, Exons); double totalFPKMCalcTime = (System.currentTimeMillis() - currentTime) / 1000F; Expressions.removeAll(Expressions); // explicitly deleting to free up memory System.out.println("Reading mapped reads SAM file...."); numberOfLines = readsFileChrBoundaries.get(arrayPosition) - readsFileChrBoundaries.get(arrayPosition - 1); ArrayList<MappedReads> mappedReads = new ArrayList<MappedReads>(); currentTime = System.currentTimeMillis(); mappedReads = MappedReads.readMappedReads(inputSAMData, chromosome, numberOfLines); double totalReadsReadTime = (System.currentTimeMillis() - currentTime) / 1000F; MappedReads.sort(mappedReads); int numberOfReads = mappedReads.size(); System.out.println("Reading reference genome file...."); String referenceFileName = referenceDirectory + "/chr" + chromosome + ".fa"; currentTime = System.currentTimeMillis(); RandomAccessFile inputReference = new RandomAccessFile(referenceFileName, "r"); for (Exon e : Exons) { e.getReferenceSequence(inputReference); } double totalRefCalcTime = (System.currentTimeMillis() - currentTime) / 1000F; System.out.println("Calculating SNPs...."); currentTime = System.currentTimeMillis(); Exon.getSNPs(Exons, mappedReads); double totalSNPsCalcTime = (System.currentTimeMillis() - currentTime) / 1000F; mappedReads.removeAll(mappedReads); System.out.println("Calculating States...."); currentTime = System.currentTimeMillis(); HiddenMarkovModel.getStates(Exons); double totalStateCalcTime = (System.currentTimeMillis() - currentTime) / 1000F; // Print output if (outputFileName.equals("")) { // print to stdout for (Exon e : Exons) System.out.println(e); } else { Writer output = new BufferedWriter(new FileWriter(outputFileName)); for (Exon e : Exons) output.write(e + "\n"); output.close(); } // prints the timing metrics to std out if (printTimingMetrics) { double endTime = System.currentTimeMillis(); totalTime = (endTime - startTime) / 1000F; System.out.println("Total Time: " + totalTime); System.out.println( "Time for reading exons file : " + totalExonReadTime + ", " + Exons.size()); System.out.println( "Time for reading expression file : " + totalExprReadTime + ", " + numberOfExpr); System.out.println( "Time for reading mapped reads file: " + totalReadsReadTime + ", " + numberOfReads); System.out.println("Time for getting reference seq : " + totalRefCalcTime); System.out.println("Time for calculating FPKM : " + totalFPKMCalcTime); System.out.println("Time for calculating Num of SNPs : " + totalSNPsCalcTime); System.out.println("Time for calculating States : " + totalStateCalcTime); } } } catch (Exception e) { System.err.println("Exception: " + e.getMessage()); e.printStackTrace(); } }