List of usage examples for java.util LinkedHashMap isEmpty
boolean isEmpty();
From source file:es.eucm.eadventure.tracking.prv.gleaner.GleanerLogConsumer.java
private Map<String, Object> convert(GameLogEntry entry) { LinkedHashMap<String, Object> trace = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> data = new LinkedHashMap<String, Object>(); try {//from w w w . j a va 2s . c o m // High level if (entry.getElementName().equals("h")) { trace.put("timeStamp", Long.parseLong(entry.getAttributeValue("ms")) + initTimeStamp); trace.put("type", "logic"); if (entry.getAttributeValue("o") != null) { trace.put("target", entry.getAttributeValue("o")); } if (entry.getAttributeValue("t") != null) { if (trace.containsKey("target")) { data.put("target", entry.getAttributeValue("t")); } else { trace.put("target", entry.getAttributeValue("t")); } } if ("scn".equals(entry.getAttributeValue("a"))) { if (currentPhase != null) { // Send phase_end trace LinkedHashMap<String, Object> endPhaseTrace = new LinkedHashMap<String, Object>(); endPhaseTrace.put("type", "logic"); endPhaseTrace.put("timeStamp", (Long) trace.get("timeStamp") - 1); endPhaseTrace.put("event", "phase_end"); endPhaseTrace.put("target", currentPhase); traces.add(endPhaseTrace); } // Set phase_start trace trace.put("event", "phase_start"); this.currentPhase = trace.get("target").toString(); } else if (entry.getAttributeValue("a") != null) { trace.put("event", entry.getAttributeValue("a")); } else if (entry.getAttributeValue("e") != null) { // Activate / Deactive flag String attValue = entry.getAttributeValue("e"); trace.put("event", attValue); String varName = entry.getAttributeValue("t"); trace.put("target", varName); boolean varUpdate = false; boolean value = false; if (attValue.equals("act")) { trace.put("event", "var_update"); varUpdate = true; value = true; } else if (attValue.equals("dct")) { trace.put("event", "var_update"); varUpdate = true; value = false; } if (varUpdate) { data.put("value", value); data.put("operator", attValue); } } // Change var value if (entry.getAttributeValue("v") != null) { String valueString = entry.getAttributeValue("v"); data.put("operand", valueString); String operator = entry.getAttributeValue("e"); data.put("operator", operator); trace.put("event", "var_update"); String varName = entry.getAttributeValue("t"); trace.put("target", varName); if (entry.getAttributeValue("e") != null && (entry.getAttributeValue("e").equals(_HighLevelEvents.INCREMENT_VAR) || entry.getAttributeValue("e").equals(_HighLevelEvents.DECREMENT_VAR) || entry.getAttributeValue("e").equals(_HighLevelEvents.SET_VALUE) || entry.getAttributeValue("e").equals(_HighLevelEvents.WAIT_TIME))) { Integer value = Integer.parseInt(entry.getAttributeValue("v")); if (!vars.containsKey(trace.get("target"))) { vars.put(varName, 0); } if (operator.equals("set")) { vars.put(varName, value); } else if (operator.equals("inc")) { vars.put(varName, value + vars.get(varName)); } else if (operator.equals("dec")) { vars.put(varName, value - vars.get(varName)); } data.put("value", vars.get(varName)); } } // Other data if (entry.getAttributeValue("ix") != null) { data.put("ix", Float.parseFloat(entry.getAttributeValue("ix"))); } if (entry.getAttributeValue("iy") != null) { data.put("iy", Float.parseFloat(entry.getAttributeValue("iy"))); } if (entry.getAttributeValue("x") != null) { data.put("x", Integer.parseInt(entry.getAttributeValue("x"))); } if (entry.getAttributeValue("y") != null) { data.put("y", Integer.parseInt(entry.getAttributeValue("y"))); } if (entry.getAttributeValue("dx") != null) { data.put("dx", Integer.parseInt(entry.getAttributeValue("dx"))); } if (entry.getAttributeValue("dy") != null) { data.put("dy", Integer.parseInt(entry.getAttributeValue("dy"))); } if (entry.getAttributeValue("l") != null) { data.put("l", entry.getAttributeValue("l")); } } // Low level else if (entry.getElementName().equals("l")) { trace.put("timeStamp", Long.parseLong(entry.getAttributeValue("ms")) + initTimeStamp); trace.put("type", "input"); String type = entry.getAttributeValue("t"); String action = entry.getAttributeValue("i"); if ("m".equals(type)) { trace.put("device", "mouse"); data.put("count", Integer.parseInt(entry.getAttributeValue("c"))); data.put("button", Integer.parseInt(entry.getAttributeValue("b"))); String offset = entry.getAttributeValue("off"); if (offset != null) { data.put("offset", Integer.parseInt(offset)); } } else if ("k".equals(type)) { trace.put("device", "keyboard"); if ("t".equals(action)) { data.put("ch", entry.getAttributeValue("k")); } else { data.put("keyCode", Integer.parseInt(entry.getAttributeValue("c"))); } } // Action if ("m".equals(action)) { trace.put("action", "move"); } else if ("p".equals(action)) { trace.put("action", "press"); } else if ("r".equals(action)) { trace.put("action", "release"); } else if ("c".equals(action)) { trace.put("action", "click"); } else if ("en".equals(action)) { trace.put("action", "enter"); } else if ("d".equals(action)) { trace.put("action", "drag"); } else if ("ex".equals(action)) { trace.put("action", "exit"); } else if ("t".equals(action)) { trace.put("action", "type"); } if (entry.getAttributeValue("m") != null) { data.put("modifiers", entry.getAttributeValue("m")); } if (entry.getAttributeValue("x") != null) { data.put("x", Integer.parseInt(entry.getAttributeValue("x"))); } if (entry.getAttributeValue("y") != null) { data.put("y", Integer.parseInt(entry.getAttributeValue("y"))); } } if (trace.isEmpty()) { return null; } if (!data.isEmpty()) { trace.put("data", data); } } catch (Exception e) { System.out.println("Exception while converting traces: " + e); System.out.println(entry + ""); } return trace; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public List<LinkedHashMap<String, PdfPCell>> getTotalChargesList(List<LclBlAc> chargeList, List<LclBlPiece> lclBlPiecesList) throws Exception { List<LinkedHashMap<String, PdfPCell>> l = new ArrayList<LinkedHashMap<String, PdfPCell>>(); List formattedChargesList = null; String chargeCode = ""; LinkedHashMap<String, PdfPCell> ppdChargeMap = new LinkedHashMap<String, PdfPCell>(); LinkedHashMap<String, PdfPCell> colChargeMap = new LinkedHashMap<String, PdfPCell>(); Double bundleMinchg = 0.0;/*from ww w.j a v a2 s .c o m*/ Double flatRateMinimum = 0.0; Double barrelBundlechg = 0.0; Double barrelAmount = 0.0; boolean is_OFBARR_Bundle = false; PdfPCell chargeCell = null; Paragraph p = null; if (chargeList != null && chargeList.size() > 0 && lclBlPiecesList != null) { String engmet = new PortsDAO() .getEngmet(lclbl.getFinalDestination() != null ? lclbl.getFinalDestination().getUnLocationCode() : lclbl.getPortOfDestination().getUnLocationCode()); if (!"".equalsIgnoreCase(engmet)) { if (lclBlPiecesList.size() == 1) { formattedChargesList = blUtils.getFormattedLabelChargesForBl(lclBlPiecesList, chargeList, engmet, null, true); } else { formattedChargesList = blUtils.getRolledUpChargesForBl(lclBlPiecesList, chargeList, engmet, null, true); } } if (formattedChargesList != null && !formattedChargesList.isEmpty()) { for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); if (lclBlAc.getBundleIntoOf()) { if ("TTBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { if (null != lclBlAc.getRolledupCharges()) { barrelBundlechg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { barrelBundlechg += lclBlAc.getArAmount().doubleValue(); } } else { if ("OFBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { is_OFBARR_Bundle = true; } if (null != lclBlAc.getRolledupCharges()) { bundleMinchg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { bundleMinchg += lclBlAc.getArAmount().doubleValue(); } } } } for (int k = 0; k < formattedChargesList.size(); k++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(k); if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { if (null != lclBlAc.getRolledupCharges()) { flatRateMinimum = lclBlAc.getRolledupCharges().doubleValue() + bundleMinchg; } else if (lclBlAc != null && lclBlAc.getArAmount() != null) { flatRateMinimum = lclBlAc.getArAmount().doubleValue() + bundleMinchg; } } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { if (null != lclBlAc.getRolledupCharges()) { barrelAmount = lclBlAc.getRolledupCharges().doubleValue() + barrelBundlechg; } else if (lclBlAc != null && lclBlAc.getArAmount() != null) { barrelAmount = lclBlAc.getArAmount().doubleValue() + barrelBundlechg; } } } Iterator sList = formattedChargesList.iterator(); while (sList.hasNext()) { LclBlAc lclBl = (LclBlAc) sList.next(); if (lclBl.getBundleIntoOf()) { sList.remove(); } else if (!lclBl.getPrintOnBl()) { sList.remove(); } } for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); String chargeDesc = null; String lbl = ""; if (lclBlAc.getArglMapping() != null && CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeCode())) { chargeCode = lclBlAc.getArglMapping().getChargeCode(); chargeDesc = CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeDescriptions()) ? lclBlAc.getArglMapping().getChargeDescriptions() : lclBlAc.getArglMapping().getChargeCode(); } String ar_amountLabel = ""; if (lclBlAc.getArAmount() != null) { if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { flatRateMinimum += is_OFBARR_Bundle ? barrelBundlechg : 0; if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += flatRateMinimum; } else { this.total_ar_ppd_amount += flatRateMinimum; } ar_amountLabel = NumberUtils.convertToTwoDecimal(flatRateMinimum); OCNFRT_Total = NumberUtils.convertToTwoDecimal(flatRateMinimum); } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += barrelAmount; } else { this.total_ar_ppd_amount += barrelAmount; } ar_amountLabel = NumberUtils.convertToTwoDecimal(barrelAmount); } else if (null != lclBlAc.getRolledupCharges()) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += lclBlAc.getRolledupCharges().doubleValue(); } else { this.total_ar_ppd_amount += lclBlAc.getRolledupCharges().doubleValue(); } ar_amountLabel = lclBlAc.getRolledupCharges().toString(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += lclBlAc.getArAmount().doubleValue(); } else { this.total_ar_ppd_amount += lclBlAc.getArAmount().doubleValue(); } ar_amountLabel = lclBlAc.getArAmount().toString(); } } chargeCell = new PdfPCell(); chargeCell.setBorder(0); if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { lbl = "COL"; } else { lbl = "PPD"; } chargeCell.setPaddingRight(-14); chargeCell.setPaddingLeft(-5); p = new Paragraph(7f, ar_amountLabel + " " + lbl, totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); chargeCell.addElement(p); int blAcId = lclBlAc.getId().intValue(); if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { colChargeMap.put(chargeCode + "#" + chargeDesc + "$" + blAcId, chargeCell); } else { ppdBillToSet.add(lclBlAc.getArBillToParty()); ppdChargeMap.put(chargeCode + "#" + chargeDesc + "$" + blAcId, chargeCell); } } if (!ppdChargeMap.isEmpty() && !colChargeMap.isEmpty()) { l.add(0, ppdChargeMap); l.add(1, colChargeMap); } else if (!ppdChargeMap.isEmpty()) { l.add(0, ppdChargeMap); } else if (!colChargeMap.isEmpty()) { l.add(0, colChargeMap); } } } return l; }
From source file:org.apache.solr.handler.component.AlfrescoSolrClusteringComponent.java
/** * Setup the default clustering engine.//from w w w. ja v a2s . com * @see "https://issues.apache.org/jira/browse/SOLR-5219" */ private static <T extends ClusteringEngine> void setupDefaultEngine(String type, LinkedHashMap<String, T> map) { // If there's already a default algorithm, leave it as is. if (map.containsKey(ClusteringEngine.DEFAULT_ENGINE_NAME)) { return; } // If there's no default algorithm, and there are any algorithms available, // the first definition becomes the default algorithm. if (!map.isEmpty()) { Entry<String, T> first = map.entrySet().iterator().next(); map.put(ClusteringEngine.DEFAULT_ENGINE_NAME, first.getValue()); log.info("Default engine for " + type + ": " + first.getKey()); } }
From source file:org.jahia.services.render.filter.StaticAssetsFilter.java
private Map<String, Map<String, String>> aggregate(Map<String, Map<String, String>> assets, String type) throws IOException { List<Map.Entry<String, Map<String, String>>> entries = new ArrayList<Map.Entry<String, Map<String, String>>>( assets.entrySet());/* w ww . j av a 2 s .c o m*/ Map<String, Map<String, String>> newEntries = new LinkedHashMap<String, Map<String, String>>(); for (int i = 0; i < entries.size();) { long maxLastModified = 0; LinkedHashMap<String, Resource> pathsToAggregate = new LinkedHashMap<String, Resource>(); for (; i < entries.size(); i++) { Map.Entry<String, Map<String, String>> entry = entries.get(i); String key = getKey(entry.getKey()); Resource resource = getResource(key); if (entry.getValue().isEmpty() && !excludesFromAggregateAndCompress.contains(key) && resource != null) { long lastModified = resource.lastModified(); pathsToAggregate.put(key + "_" + lastModified, resource); if (lastModified > maxLastModified) { maxLastModified = lastModified; } } else { // In case current entry should not be aggregated for whatever reason, let's stop and aggregate a group of entries preceding it. break; } } if (!pathsToAggregate.isEmpty()) { String minifiedAggregatedPath = aggregate(pathsToAggregate, type, maxLastModified); newEntries.put(Jahia.getContextPath() + minifiedAggregatedPath, new HashMap<String, String>()); } if (i < entries.size()) { // In case current entry should not be aggregated for whatever reason, add it as a non-aggregated one. Map.Entry<String, Map<String, String>> entry = entries.get(i); Resource resource; if (addLastModifiedDate && (resource = getResource(getKey(entry.getKey()))) != null) { newEntries.put(entry.getKey() + "?lastModified=" + resource.lastModified(), entry.getValue()); } else { newEntries.put(entry.getKey(), entry.getValue()); } i++; } } return newEntries; }
From source file:org.karsha.controler.UploadDocumentServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SecurityManager sm = System.getSecurityManager(); HttpSession session = request.getSession(); String userPath = request.getServletPath(); String url = ""; List items = null;/*from ww w.j a va2 s. c o m*/ if (userPath.equals("/uploaddocuments")) { boolean isMultipart = ServletFileUpload.isMultipartContent(request); if (isMultipart) { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(5000000); // FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { // items = upload. items = upload.parseRequest(request); } catch (Exception ex) { Logger.getLogger(UploadDocumentServlet.class.getName()).log(Level.SEVERE, null, ex); } HashMap requestParameters = new HashMap(); try { Iterator iterator = items.iterator(); while (iterator.hasNext()) { FileItem item = (FileItem) iterator.next(); if (item.isFormField()) { requestParameters.put(item.getFieldName(), item.getString()); } else { PDFBookmark pdfBookmark = new PDFBookmark(); byte[] fileContent = item.get(); LinkedHashMap<String, String> docSectionMap = pdfBookmark .splitPDFByBookmarks(fileContent); if (!docSectionMap.isEmpty()) { Document newDocument = new Document(); newDocument.setDocumentName(requestParameters.get("docName").toString()); newDocument.setUserId(Integer.parseInt(session.getAttribute("userId").toString())); String a = requestParameters.get("collection_type_new").toString(); newDocument.setCollectionId(Integer.parseInt(a)); // newDocument.setDocumentContent(fileContent); request.setAttribute("requestParameters", requestParameters); if (DocumentDB.isFileNameDuplicate(newDocument.getDocumentName())) { url = "/WEB-INF/view/uploaddoc.jsp?error=File name already exists, please enter another file name"; } else { //DocumentDB.insert(newDocument); DocumentDB.insertDocMetaData(newDocument); int docId = DocumentDB .getDocumentDataByDocName(requestParameters.get("docName").toString()) .getDocId(); DocSection docSection = new DocSection(); for (Map.Entry entry : docSectionMap.entrySet()) { docSection.setParentDocId(docId); docSection.setSectionName((String) entry.getKey()); byte[] byte1 = ((String) entry.getValue()).getBytes(); docSection.setSectionContent(byte1); docSection.setUserId( Integer.parseInt(session.getAttribute("userId").toString())); //To-Do set this correctly //docSection.setSectionCatog(Integer.parseInt(session.getAttribute("sectioncat").toString())); docSection.setSectionCatog(4); DocSectionDB.insert(docSection); } url = "/WEB-INF/view/uploaddoc.jsp?succuss=File Uploaded Successfully"; } } /* * check wheter text can be extracted */ /* * if(DocumentValidator.isDocValidated(fileContent)){ * * * Document newDocument = new Document(); * newDocument.setDocumentName(requestParameters.get("docName").toString()); * newDocument.setUserId(Integer.parseInt(session.getAttribute("userId").toString())); * String a = * requestParameters.get("collection_type_new").toString(); * newDocument.setCollectionId(Integer.parseInt(a)); * newDocument.setDocumentContent(fileContent); * * request.setAttribute("requestParameters", * requestParameters); * * if * (DocumentDB.isFileNameDuplicate(newDocument.getDocumentName())) * { url = "/WEB-INF/view/uploaddoc.jsp?error=File * name already exists, please enter another file * name"; } else { //DocumentDB.insert(newDocument); * DocumentDB.insertDocMetaData(newDocument); url = * "/WEB-INF/view/uploaddoc.jsp?succuss=File * Uploaded Successfully"; } * * * } * */ else { url = "/WEB-INF/view/uploaddoc.jsp?error=Text can't be extracted from file, Please try onother"; } } } } // catch (FileUploadException e) { // e.printStackTrace(); // // // } // catch (Exception e) { e.printStackTrace(); } } request.getRequestDispatcher(url).forward(request, response); } }
From source file:org.kepler.gui.kar.ImportModuleDependenciesAction.java
/** Check the dependencies and ask the user how to proceed. */ public ImportChoice checkDependencies() { ConfigurationManager cman = ConfigurationManager.getInstance(); ConfigurationProperty cprop = cman.getProperty(KARFile.KARFILE_CONFIG_PROP_MODULE); ConfigurationProperty KARComplianceProp = cprop.getProperty(KARFile.KAR_COMPLIANCE_PROPERTY_NAME); String KARCompliance = KARComplianceProp.getValue(); final ArrayList<String> dependencies = new ArrayList<String>(); try {//from w w w. j av a 2 s. c o m if (_dependencies != null) { // dependencies were given dependencies.addAll(_dependencies); } else if (_archiveFile != null) { // kar file was given KARFile karFile = null; try { karFile = new KARFile(_archiveFile); dependencies.addAll(karFile.getModuleDependencies()); } finally { if (karFile != null) { karFile.close(); } } } else { // karxml was given dependencies.addAll(_karXml.getModuleDependencies()); } } catch (Exception ex) { ex.printStackTrace(); } //ModuleTree moduleTree = ModuleTree.instance(); //String currentModList = formattedCurrentModuleList(moduleTree); boolean dependencyMissingFullVersion = !(ModuleDependencyUtil .isDependencyVersioningInfoComplete(dependencies)); LinkedHashMap<String, Version> unsatisfiedDependencies = ModuleDependencyUtil .getUnsatisfiedDependencies(dependencies); String keplerRestartMessage = null; String unableToOpenOrExportInStrictKARComplianceMessage = null; String manualActionRequired = null; String unSats = formattedUnsatisfiedDependencies(unsatisfiedDependencies); final List<String> unSatsAsList = new ArrayList<String>(unsatisfiedDependencies.keySet()); String formattedDependencies = formatDependencies(dependencies); String htmlBGColor = "#" + Integer.toHexString(UIManager.getColor("OptionPane.background").getRGB() & 0x00ffffff); //XXX augment if additional strictness levels added if (KARCompliance.equals(KARFile.KAR_COMPLIANCE_STRICT)) { if (dependencyMissingFullVersion) { if (_exportMode) { unableToOpenOrExportInStrictKARComplianceMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "lacks complete versioning information in its module-dependency list:<strong>" + formattedDependencies + "</strong><br><br>You must change your KAR opening compliance " + "preference to Relaxed before trying to export this KAR.<br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { unableToOpenOrExportInStrictKARComplianceMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "lacks complete versioning information in its module-dependency list:<strong>" + formattedDependencies + "</strong><br><br>You must change your KAR opening compliance " + "preference to Relaxed before trying to open this KAR.<br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (!unsatisfiedDependencies.isEmpty()) { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To export this KAR in<br>" + "Strict mode you must restart Kepler with these additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To open this KAR in<br>" + "Strict mode you must restart Kepler with these additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To export this KAR in<br>" + "Strict mode you must restart Kepler using this module set in this order:<strong>" + formattedDependencies + "</strong><br><br>Would you like to restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">Your KAR opening compliance preference is set to Strict. To open this KAR in<br>" + "Strict mode you must restart Kepler using this module set in this order:<strong>" + formattedDependencies + "</strong><br><br>Would you like to restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost, and auto-updating turned off if it's on<br>" + "(re-enable using the Tools=>Module Manager...)</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } } } else if (KARCompliance.equals(KARFile.KAR_COMPLIANCE_RELAXED)) { if (dependencyMissingFullVersion) { // if there's a dependency missing full version info, situation should be either 1) a 2.0 kar, in which case // it lacks the full mod dep list and so user must use MM, or 2) it's a 2.1 kar created from an svn // checkout of kepler, in which case, the power user should use the build system to // change to unreleased versions of a suite containing the required modules as necessary if (_exportMode) { manualActionRequired = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "requires the following unsatisfied module dependencies that lack complete versioning information:<strong>" + unSats + "</strong><br><br>Please use the Module Manager or build system to change to a suite that uses these modules.</strong>" + "<br><br>You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { manualActionRequired = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR " + "requires the following unsatisfied module dependencies that lack complete versioning information:<strong>" + unSats + "</strong><br><br>Please use the Module Manager or build system to change to a suite that uses these modules.</strong>" + "<br><br>You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { if (!unsatisfiedDependencies.isEmpty()) { if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to " + "download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "additional module(s):<strong>" + unSats + "</strong><br><br>Would you like to " + "download (if necessary) and restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } else { //THIS SHOULDN'T HAPPEN log.error( "ImportModuleDependenciesAction WARNING unsatisfiedDependencies is empty, this shouldn't happen, but is non fatal"); if (_exportMode) { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "module(s):<strong>" + formattedDependencies + "</strong><br><br>Would you like to " + "restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can Force Export, but some artifacts may not be included in the KAR.</body></html>"; } else { keplerRestartMessage = "<html><body bgcolor=\"" + htmlBGColor + "\">This KAR requires you restart Kepler with these " + "module(s):<strong>" + formattedDependencies + "</strong><br><br>Would you like to " + "restart Kepler using these modules now?" + "<br><br><strong>WARNING: All unsaved work will be lost</strong><br><br>" + "You can attempt a Force Open, but this may cause unexpected errors.</body></html>"; } } } } String[] optionsOkForceopen = { "OK", "Force Open" }; String[] optionsOkForceexport = { "OK", "Force Export" }; String[] optionsYesNoForceopen = { "Yes", "No", "Force Open" }; String[] optionsYesNoForceexport = { "Yes", "No", "Force Export" }; if (unableToOpenOrExportInStrictKARComplianceMessage != null) { JLabel label = new JLabel(unableToOpenOrExportInStrictKARComplianceMessage); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Unable to export in Strict mode", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceexport, optionsOkForceexport[0]); if (optionsOkForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Unable to open in Strict mode", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceopen, optionsOkForceopen[0]); if (optionsOkForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } return ImportChoice.DO_NOTHING; } if (manualActionRequired != null) { JLabel label = new JLabel(manualActionRequired); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Use Module Manager", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceexport, optionsOkForceexport[0]); if (optionsOkForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Use Module Manager", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsOkForceopen, optionsOkForceopen[0]); if (optionsOkForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } return ImportChoice.DO_NOTHING; } JLabel label = new JLabel(keplerRestartMessage); if (_exportMode) { int choice = JOptionPane.showOptionDialog(parent, label, "Confirm Kepler Restart", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsYesNoForceexport, optionsYesNoForceexport[1]); if (optionsYesNoForceexport[choice] == "No") { // user doesn't want to download. return ImportChoice.DO_NOTHING; } else if (optionsYesNoForceexport[choice].equals("Force Export")) { return ImportChoice.FORCE_EXPORT; } } else { int choice = JOptionPane.showOptionDialog(parent, label, "Confirm Kepler Restart", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, optionsYesNoForceopen, optionsYesNoForceopen[1]); if (optionsYesNoForceopen[choice] == "No") { // user doesn't want to download. return ImportChoice.DO_NOTHING; } else if (optionsYesNoForceopen[choice].equals("Force Open")) { return ImportChoice.FORCE_OPEN; } } parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override public Void doInBackground() throws Exception { try { //download needed modules ModuleDownloader downloader = new ModuleDownloader(); ModuleDownloadProgressMonitor mdpm = new ModuleDownloadProgressMonitor(parent); downloader.addListener(mdpm); if (!unSatsAsList.isEmpty()) { downloader.downloadModules(unSatsAsList); } else { // this shouldn't happen, but if it does, resorting // to downloading all dependencies should be a safe bet log.error("ImportModuleDependenciesAction WARNING unSatsAsList is empty, " + "this shouldn't happen, but is non fatal"); downloader.downloadModules(dependencies); } //rewrite modules.txt ModulesTxt modulesTxt = ModulesTxt.instance(); modulesTxt.clear(); for (String dependency : dependencies) { //System.out.println("ImportModuleDependency doInBackground modulesTxt.add("+dependency+")"); modulesTxt.add(dependency); } modulesTxt.write(); //delete and write "unknown" to current-suite.txt CurrentSuiteTxt.delete(); CurrentSuiteTxt.setName("unknown"); // if KARCompliance is Strict, user is restarting w/ specific versions of modules // and we don't want them to potentially auto update on restart to available patches turnOffAutoUpdatesIfStrictMode(); //restart Kepler using new modules spawnNewKeplerAndQuitCurrent(); return null; } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog(parent, "Error downloading module: " + ex.getMessage()); return null; } } @Override protected void done() { //never reached. } }; worker.execute(); parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return ImportChoice.DOWNLOADING_AND_RESTARTING; }
From source file:org.kuali.rice.kew.docsearch.DocumentSearchCriteriaProcessorKEWAdapter.java
/** * Modifies the DataDictionary-defined applicationDocumentStatus field control to reflect whether the DocumentType * has specified a list of valid application document statuses (in which case a select control is rendered), or whether * it is free form (in which case a text control is rendered) * * @param field the applicationDocumentStatus field * @param documentType the document type *///from ww w . jav a 2s. com protected void applyApplicationDocumentStatusCustomizations(Field field, DocumentType documentType) { if (documentType.getValidApplicationStatuses() == null || documentType.getValidApplicationStatuses().size() == 0) { // use a text input field // StandardSearchCriteriaField(String fieldKey, String propertyName, String fieldType, String datePickerKey, String labelMessageKey, String helpMessageKeyArgument, boolean hidden, String displayOnlyPropertyName, String lookupableImplServiceName, boolean lookupTypeRequired) // new StandardSearchCriteriaField(DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS,"criteria.appDocStatus",StandardSearchCriteriaField.TEXT,null,null,"DocSearchApplicationDocStatus",false,null,null,false)); // String fieldKey DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS field.setFieldType(Field.TEXT); } else { // multiselect // String fieldKey DocumentSearchCriteriaProcessor.CRITERIA_KEY_APP_DOC_STATUS + "_VALUES" field.setFieldType(Field.MULTISELECT); List<KeyValue> validValues = new ArrayList<KeyValue>(); // add to set for quick membership check and removal. LinkedHashSet to preserve order Set<String> statusesToDisplay = new LinkedHashSet<String>(); for (ApplicationDocumentStatus status : documentType.getValidApplicationStatuses()) { statusesToDisplay.add(status.getStatusName()); } // KULRICE-7786: support for groups (categories) of application document statuses LinkedHashMap<String, List<String>> appDocStatusCategories = ApplicationDocumentStatusUtils .getApplicationDocumentStatusCategories(documentType.getName()); if (!appDocStatusCategories.isEmpty()) { for (Map.Entry<String, List<String>> group : appDocStatusCategories.entrySet()) { boolean addedCategoryHeading = false; // only add category if it has valid members for (String member : group.getValue()) { if (statusesToDisplay.remove(member)) { // remove them from the set as we display them if (!addedCategoryHeading) { addedCategoryHeading = true; validValues.add(new ConcreteKeyValue("category:" + group.getKey(), group.getKey())); } validValues.add(new ConcreteKeyValue(member, "- " + member)); } } } } // add remaining statuses, if any. for (String member : statusesToDisplay) { validValues.add(new ConcreteKeyValue(member, member)); } field.setFieldValidValues(validValues); // size the multiselect as appropriate if (validValues.size() > 5) { field.setSize(5); } else { field.setSize(validValues.size()); } //dropDown.setOptionsCollectionProperty("validApplicationStatuses"); //dropDown.setCollectionKeyProperty("statusName"); //dropDown.setCollectionLabelProperty("statusName"); //dropDown.setEmptyCollectionMessage("Select a document status."); } }
From source file:org.kutkaitis.timetable2.timetable.MonteCarlo.java
private boolean isStudentInOneLectureAtTheTime(Teacher teacher, List<Group> teachersGroups, Group group, int lectureNumber, LinkedHashMap<String, LinkedHashMap> dayTimeTable) { boolean mandatoryConditionsMet = true; if (group != null) { // System.out.println("Grupe idejimui: " + group.getGroupName()); List<Student> groupStudents = group.getStudents(); Collection<LinkedHashMap> teachersTimeTables = dayTimeTable.values(); // System.out.println("teachersTimeTables before if: " + teachersTimeTables); for (LinkedHashMap<String, String> teachersTimeTable : teachersTimeTables) { // System.out.println("Iskviete fore"); if (teachersTimeTable.isEmpty()) { mandatoryConditionsMet = true; continue; }/*from ww w . j a v a 2 s . c om*/ // System.out.println("teachersTimeTable: " + teachersTimeTable); String groupNameToSplit = teachersTimeTable.get(String.valueOf(lectureNumber)); if (groupNameToSplit == null) { mandatoryConditionsMet = true; continue; } String[] splittedGroupNames = groupNameToSplit.split(":"); String groupName = splittedGroupNames[1].trim(); // System.out.println("Group name: " + groupName); Group groupToCheck = studentsMockDataFiller.getGroups().get(groupName); // System.out.println("groupToCheck: " + groupToCheck); boolean contains = true; if (StringUtils.equals(groupName, "-----")) { contains = false; } if (groupToCheck != null) { // System.out.println("Group to check: " + groupToCheck.getGroupName()); contains = CollectionUtils.containsAny(groupStudents, groupToCheck.getStudents()); // System.out.println("Contains: " + contains); } if (contains == false) { mandatoryConditionsMet = true; } else { mandatoryConditionsMet = false; return mandatoryConditionsMet; } } } else { mandatoryConditionsMet = false; } return mandatoryConditionsMet; }
From source file:org.kutkaitis.timetable2.timetable.MonteCarlo.java
private boolean isOneGroupInOneClassroom(Group group, int lectureNumber, LinkedHashMap<String, LinkedHashMap> dayTimeTable) { boolean oneLectureInOneRoom = true; if (group != null) { ClassRoom groupsRoom = group.getClassRoom(); String classRoomNumber = groupsRoom.getRoomNumber(); // System.out.println("Group to add: " + group.getGroupName()); Collection<LinkedHashMap> teachersTimeTables = dayTimeTable.values(); for (LinkedHashMap<String, String> teachersTimeTable : teachersTimeTables) { if (teachersTimeTable.isEmpty()) { oneLectureInOneRoom = true; continue; }/*from ww w. j a v a 2 s . c o m*/ String groupNameToSplit = teachersTimeTable.get(String.valueOf(lectureNumber)); if (groupNameToSplit == null) { oneLectureInOneRoom = true; continue; } String[] splittedGroupNames = groupNameToSplit.split(":"); String groupName = splittedGroupNames[1].trim(); Group groupToCheck = studentsMockDataFiller.getGroups().get(groupName); boolean roomBusy = true; if (StringUtils.equals(groupName, "-----")) { roomBusy = false; } if (groupToCheck != null) { // System.out.println("Group to check: " + groupToCheck.getGroupName()); roomBusy = StringUtils.equals(classRoomNumber, groupToCheck.getClassRoom().getRoomNumber()); // System.out.println("freeRoom: " + roomBusy); } if (roomBusy == false) { oneLectureInOneRoom = true; } else { oneLectureInOneRoom = false; return oneLectureInOneRoom; } } } else { oneLectureInOneRoom = false; } return oneLectureInOneRoom; }
From source file:org.mule.util.JarUtils.java
public static void createJarFileEntries(File jarFile, LinkedHashMap entries) throws Exception { JarOutputStream jarStream = null; FileOutputStream fileStream = null; if (jarFile != null) { logger.debug("Creating jar file " + jarFile.getAbsolutePath()); try {/*from ww w. java 2 s . co m*/ fileStream = new FileOutputStream(jarFile); jarStream = new JarOutputStream(fileStream); if (entries != null && !entries.isEmpty()) { Iterator iter = entries.keySet().iterator(); while (iter.hasNext()) { String jarFilePath = (String) iter.next(); Object content = entries.get(jarFilePath); JarEntry entry = new JarEntry(jarFilePath); jarStream.putNextEntry(entry); logger.debug("Adding jar entry " + jarFilePath + " to " + jarFile.getAbsolutePath()); if (content instanceof String) { writeJarEntry(jarStream, ((String) content).getBytes()); } else if (content instanceof byte[]) { writeJarEntry(jarStream, (byte[]) content); } else if (content instanceof File) { writeJarEntry(jarStream, (File) content); } } } jarStream.flush(); fileStream.getFD().sync(); } finally { if (jarStream != null) { try { jarStream.close(); } catch (Exception jarNotClosed) { logger.debug(jarNotClosed); } } if (fileStream != null) { try { fileStream.close(); } catch (Exception fileNotClosed) { logger.debug(fileNotClosed); } } } } }