/** * returns list of output lines * * @param userId user id * @return sessionId session id object */ public static List<SessionOutput> getOutput(Connection con, Long userId) { List<SessionOutput> outputList = new ArrayList<SessionOutput>(); UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput != null) { for (Long key : userSessionsOutput.getSessionOutputMap().keySet()) { // get output chars and set to output try { SessionOutput sessionOutput = (SessionOutput) BeanUtils.cloneBean(userSessionsOutput.getSessionOutputMap().get(key)); outputList.add(sessionOutput); SessionAuditDB.insertTerminalLog(con, sessionOutput); userSessionsOutput.getSessionOutputMap().get(key).setOutput(""); } catch (Exception ex) { ex.printStackTrace(); } } } return outputList; }
public static void main(String[] args) { Long aa = null; // System.out.println(aa.longValue()); // Long a = 9L-8L; // Long b = 3L-2L; // System.out.println(a.equals(b)); // System.out.println(a == b); // System.out.println(0L+aa); String s1 = "09:01:22"; String s2 = "09:01:26"; // System.out.println(s1.compareTo(s2)); // System.out.println(s1.compareTo("09:01:22")); // System.out.println(s1.compareTo("09:01:12")); String s3 = (Integer.parseInt(s2.substring(0, 2)) + 24) + s2.substring(2); System.out.println(s3); JavaTest aa1 = new JavaTest(); aa1.setA("a"); aa1.setB("bb"); try { JavaTest bb1 = (JavaTest) BeanUtils.cloneBean(aa1); System.out.println(aa1 == bb1); System.out.println(aa1.a == bb1.a); System.out.println(aa1.b == bb1.b); System.out.println(aa1.b.equals(bb1.b)); System.out.println(aa1.a.equals(bb1.a)); System.out.println(aa1.equals(bb1)); System.out.println(aa1.a); System.out.println(aa1.b); System.out.println(bb1.a); System.out.println(bb1.b); bb1.setA("1g"); bb1.setB("1v"); System.out.println(aa1 == bb1); System.out.println(aa1.a == bb1.a); System.out.println(aa1.b == bb1.b); System.out.println(aa1.b.equals(bb1.b)); System.out.println(aa1.a.equals(bb1.a)); System.out.println(aa1.equals(bb1)); System.out.println(aa1.a); System.out.println(aa1.b); System.out.println(bb1.a); System.out.println(bb1.b); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public void verAuditoria(ActionEvent evento) throws IllegalAccessException { try { this.setDocente(new Docente()); this.setDocente((Docente) BeanUtils.cloneBean(this.getDocenteSeleccionado())); super.verAuditoria(); } catch (Exception ex) { MensajesGenericos.errorCopyProperties(); } }
public synchronized void save(Contact entry) { if (entry.getId() == null) { entry.setId(nextId++); } try { entry = (Contact) BeanUtils.cloneBean(entry); } catch (Exception ex) { throw new RuntimeException(ex); } contacts.put(entry.getId(), entry); }
public static String shopBrowseUrl(ItemSearch sourceItemSearch, String alias, String strChange) { ItemSearch itemSearch; try { itemSearch = (ItemSearch) BeanUtils.cloneBean(sourceItemSearch); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex) { itemSearch = new ItemSearch(); } if (strChange != null && !strChange.equals("")) { List<Map<String, String>> changes = (List<Map<String, String>>) JsonUtils.decode(strChange, new TypeToken<List<Map<String, String>>>() {}.getType()); for (Map<String, String> ch : changes) { String op = ch.get("op"); String key = ch.get("key"); String val = ch.get("val"); if (key.equals("cid")) { itemSearch.setShopCategoryId(val); } if (key.equals("keyword")) { if (op.equals("mk")) { itemSearch.setKeyword(val); } else if (op.equals("rm")) { itemSearch.setKeyword(null); } } if (key.equals("promotionId")) { if (op.equals("mk")) { itemSearch.setPromotionId(val); } else if (op.equals("rm")) { itemSearch.setPromotionId(null); } } if (key.equals("order")) { try { itemSearch.setOrderBy(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("page")) { try { itemSearch.setPageIndex(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } } } return UrlUtils.shopBrowseUrl(itemSearch, alias); }
public void modificar(ActionEvent evento) { this.setDocente(new Docente()); try { this.docente = (Docente) BeanUtils.cloneBean(this.docenteSeleccionado); this.docenteServicio.actualizar(this.docente); // //Invariable Objetos de Auditoria // this.docente.setUsrModificacion(usrSesion.getCodigo()); // this.docente.setFmodificacion(new Date()); super.modificar(); } catch (Exception ex) { MensajesGenericos.errorCopyProperties(); } }
/** * Retorna o clone do objet informado. * * @param bean o objeto a ser clonado. * @return o clone do objet informado. * @throws SystemException Caso ocorra alguma exceção ao tentar fazer o clone do objeto. */ public static Object cloneBean(Object bean) throws SystemException { Object clone = null; if (bean != null) { try { clone = BeanUtils.cloneBean(bean); } catch (Exception e) { tratarExcecao(e); } } return clone; }
/** * Clones the ActionConfig and its children, replacing various properties with the values of the * wildcard-matched strings. * * @param path The requested path * @param orig The original ActionConfig * @param vars A Map of wildcard-matched strings * @return A cloned ActionConfig with appropriate properties replaced with wildcard-matched values */ protected ActionConfig convertActionConfig(String path, ActionConfig orig, Map vars) { ActionConfig config = null; try { config = (ActionConfig) BeanUtils.cloneBean(orig); } catch (Exception ex) { log.warn("Unable to clone action config, recommend not using " + "wildcards", ex); return null; } config.setName(convertParam(orig.getName(), vars)); if (path.length() == 0 || path.charAt(0) != '/') { path = "/" + path; } config.setPath(path); config.setType(convertParam(orig.getType(), vars)); config.setRoles(convertParam(orig.getRoles(), vars)); config.setParameter(convertParam(orig.getParameter(), vars)); config.setAttribute(convertParam(orig.getAttribute(), vars)); config.setForward(convertParam(orig.getForward(), vars)); config.setInclude(convertParam(orig.getInclude(), vars)); config.setInput(convertParam(orig.getInput(), vars)); ForwardConfig[] fConfigs = orig.findForwardConfigs(); ForwardConfig cfg; for (int x = 0; x < fConfigs.length; x++) { cfg = new ActionForward(); cfg.setContextRelative(fConfigs[x].getContextRelative()); cfg.setName(fConfigs[x].getName()); cfg.setPath(convertParam(fConfigs[x].getPath(), vars)); cfg.setRedirect(fConfigs[x].getRedirect()); config.removeForwardConfig(fConfigs[x]); config.addForwardConfig(cfg); } ExceptionConfig[] exConfigs = orig.findExceptionConfigs(); for (int x = 0; x < exConfigs.length; x++) { config.addExceptionConfig(exConfigs[x]); } config.freeze(); return config; }
/** 线程执行体 */ public void run() { logger.info("插件管理应用启动"); // 启动所有接收分析管理线程 VehicleMessageBean vehicleMessage = null; Vector<PacketAnalyser> vA; int thnum = 0; // 获取插件KEY List<String> kyList = new ArrayList<String>(); Set<String> st = taAnalyser.keySet(); Iterator<String> it = st.iterator(); while (it.hasNext()) { kyList.add(it.next()); } // End while while (isRunning) { try { vehicleMessage = vPacket.take(); // String alarmType = vehicleMessage.getAlarmtype(); // logger.info("插件管理器收到数据,准备分发给业务类。-----"+alarmType); // String[] typeArray = alarmType.split(","); // 按类型进行分配 if (isSort(vehicleMessage)) { for (String type : kyList) { vA = taAnalyser.get(type); if (vA == null || vA.size() == 0) continue; thnum = (int) (Math.abs(vehicleMessage.getVid().hashCode()) % vA.size()); // logger.info("插件管理器将收到的数据----分发给业务类。-----"+type+"下的子线程>>"+thnum); // 此处需要克隆一下,然后将消息分发到不同的队列 add liangjian by 2012-11-15 15:44:29 VehicleMessageBean vehicleMessageNew = (VehicleMessageBean) BeanUtils.cloneBean(vehicleMessage); processCoordinatesByACC(vehicleMessageNew, vehicleMessageNew.getVid()); vA.elementAt(thnum).addPacket(vehicleMessageNew); } } // logger.debug("插件管理线程" + threadId + "," + vPacket.size()); } catch (Exception e) { logger.error("插件管理线程出错.", e); } } // End While logger.info("插件管理服务停止"); }
// Adds to each Service template the general criteria for the CSA // (each service template can have is own set of criteria, but if a global criteria is defined // each component must use it.) private void generalizeCSACriteria() { ArrayList<ServiceTemplate> comps = new ArrayList<ServiceTemplate>(); ArrayList<Criterion> crit = new ArrayList<Criterion>(); comps = this.data.getServiceTemplates(); crit = this.data.getCriteria(); for (ServiceTemplate c : comps) { for (Criterion cr : crit) { try { Criterion temp = (Criterion) BeanUtils.cloneBean(cr); c.addCrit(temp); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) { e.printStackTrace(); } } } }
public User cloneUser() { User newObj = null; try { newObj = (User) org.apache.commons.beanutils.BeanUtils.cloneBean(this); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (java.lang.reflect.InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } return newObj; }
@Override protected List<ParentIdHolder<Property>> afterProcessing( List<ParentIdHolder<Property>> processedItems, List<Mrsty> originalItems) { List<ParentIdHolder<Property>> buffer = new ArrayList<ParentIdHolder<Property>>(); List<String> codes = mrconsoStagingDao.getCodes(getGroupCui(originalItems), sab); for (String code : codes) { for (ParentIdHolder<Property> prop : processedItems) { try { ParentIdHolder<Property> holder = new ParentIdHolder<Property>(); // shallow clone the bean, as deep cloning is too expensive to do this many times Property clonedProp = (Property) BeanUtils.cloneBean(prop.getItem()); String codingSchemeUri = codingSchemeIdSetter.getCodingSchemeUri(); String version = codingSchemeIdSetter.getCodingSchemeVersion(); String codingSchemeId = getCodingSchemeId(codingSchemeUri, version); String entityId = getEntityIdForCode(codingSchemeId, code, codingSchemeIdSetter.getCodingSchemeName()); holder.setItem(clonedProp); holder.setParentId(entityId); holder.setCodingSchemeIdSetter(this.codingSchemeIdSetter); buffer.add(holder); } catch (Exception e) { throw new RuntimeException(e); } } } parameterizedlistIdSetter.addIds(buffer, getGroupCui(originalItems)); return buffer; }
@Override public void copyByBusinessFormTemplateId(String oldTemplateId, String newTemplateId) { List<BusinessBaseTemplate> list = businessBaseTemplateDao.queryBybusinessBaseTemplate(oldTemplateId); for (BusinessBaseTemplate businessBaseTemplate : list) { try { BusinessBaseTemplate newBusinessBaseTemplate = (BusinessBaseTemplate) BeanUtils.cloneBean(businessBaseTemplate); newBusinessBaseTemplate.setTemplateId(newTemplateId); newBusinessBaseTemplate.setId(null); this.businessBaseTemplateDao.save(newBusinessBaseTemplate); templateFieldService.copyByBusinessBaseId( businessBaseTemplate.getId(), newBusinessBaseTemplate.getId()); } catch (IllegalAccessException e) { log.error(e); } catch (InstantiationException e) { log.error(e); } catch (InvocationTargetException e) { log.error(e); } catch (NoSuchMethodException e) { log.error(e); } } }
public static String modelDetailUrl(ItemSearch sourceItemSearch, String name, String strChange) { ItemSearch itemSearch; try { itemSearch = (ItemSearch) BeanUtils.cloneBean(sourceItemSearch); itemSearch.setModelIds(new ArrayList<>(sourceItemSearch.getModelIds())); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex) { itemSearch = new ItemSearch(); } if (strChange != null && !strChange.equals("")) { List<Map<String, String>> changes = (List<Map<String, String>>) JsonUtils.decode(strChange, new TypeToken<List<Map<String, String>>>() {}.getType()); for (Map<String, String> ch : changes) { String op = ch.get("op"); String key = ch.get("key"); String val = ch.get("val"); if (key.equals("cities")) { if (op.equals("mk")) { itemSearch.getCityIds().remove(val); itemSearch.getCityIds().add(val); } else if (op.equals("rm")) { itemSearch.getCityIds().remove(val); } else if (op.equals("cl")) { itemSearch.getCityIds().clear(); } } if (key.equals("type")) { try { if (val.equals("BUYNOW")) { itemSearch.setListingType(ListingType.BUYNOW); } else if (val.equals("AUCTION")) { itemSearch.setListingType(ListingType.AUCTION); } else { itemSearch.setListingType(null); } } catch (NumberFormatException ex) { } } if (key.equals("cod")) { if (op.equals("mk")) { itemSearch.setCod(true); } else if (op.equals("rm")) { itemSearch.setCod(false); } } if (key.equals("manuf")) { if (op.equals("mk")) { itemSearch.setManufacturerIds(new ArrayList<String>()); } } if (key.equals("promotion")) { if (op.equals("mk")) { itemSearch.setPromotion(true); } else if (op.equals("rm")) { itemSearch.setPromotion(false); } } if (key.equals("condition")) { try { if (val.equals("NEW")) { itemSearch.setCondition(Condition.NEW); } else if (val.equals("OLD")) { itemSearch.setCondition(Condition.OLD); } else { itemSearch.setListingType(null); } } catch (NumberFormatException ex) { } } if (key.equals("order")) { try { itemSearch.setOrderBy(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("page")) { try { itemSearch.setPageIndex(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } } } String url; if (itemSearch.getModelIds() != null && itemSearch.getModelIds().size() > 0) { url = "/model/" + itemSearch.getModelIds().get(0) + "/" + TextUtils.createAlias(name) + ".html"; } else { url = "/tim-kiem-model.html"; } String search = ""; String keyword = itemSearch.getKeyword(); int pageIndex = itemSearch.getPageIndex(); if ((itemSearch.getManufacturerIds() != null && !itemSearch.getManufacturerIds().isEmpty()) || (itemSearch.getCityIds() != null && !itemSearch.getCityIds().isEmpty()) || itemSearch.getOrderBy() > 0 || (itemSearch.getProperties() != null && !itemSearch.getProperties().isEmpty()) || (itemSearch.getCondition() == Condition.NEW || itemSearch.getCondition() == Condition.OLD) || (itemSearch.getListingType() == ListingType.AUCTION || itemSearch.getListingType() == ListingType.BUYNOW) || (itemSearch.getPriceFrom() > 0 || itemSearch.getPriceTo() > 0) || itemSearch.isCod() || itemSearch.isFreeShip() || itemSearch.isOnlinePayment() || itemSearch.isPromotion()) { itemSearch.setKeyword(null); search = "?filter=" + Base64.encodeBase64String(StringUtils.getBytesUtf8(new Gson().toJson(itemSearch))); } if (keyword != null && !keyword.equals("")) { url += "?keyword=" + keyword.replaceAll("\\s+", "\\+"); url = pageIndex <= 1 ? url : url + "&page=" + pageIndex; return search.equals("") ? url : url + "&" + search; } else { return search.equals("") ? (pageIndex <= 1 ? url : url + "?page=" + pageIndex) : ((pageIndex <= 1 ? (url + "?") : (url + "?page=" + pageIndex + "&")) + search); } }
public static String modelBrowseUrl( ModelSearch sourceModelSearch, String name, String strChange) { ModelSearch modelSearch; try { modelSearch = (ModelSearch) BeanUtils.cloneBean(sourceModelSearch); modelSearch.setManufacturerIds(new ArrayList<>(sourceModelSearch.getManufacturerIds())); modelSearch.setProperties(new ArrayList<>(sourceModelSearch.getProperties())); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex) { modelSearch = new ModelSearch(); } if (strChange != null && !strChange.equals("")) { List<Map<String, String>> changes = (List<Map<String, String>>) JsonUtils.decode(strChange, new TypeToken<List<Map<String, String>>>() {}.getType()); for (Map<String, String> ch : changes) { String op = ch.get("op"); String key = ch.get("key"); String val = ch.get("val"); if (key.equals("cid")) { modelSearch.setCategoryId(val); } if (key.equals("keyword")) { if (op.equals("mk")) { modelSearch.setKeyword(val); } else if (op.equals("rm")) { modelSearch.setKeyword(null); } } if (key.equals("manufacturers")) { if (op.equals("mk")) { modelSearch.getManufacturerIds().remove(val); modelSearch.getManufacturerIds().add(val); } else if (op.equals("rm")) { modelSearch.getManufacturerIds().remove(val); } else if (op.equals("cl")) { modelSearch.getManufacturerIds().clear(); } } if (key.equals("properties")) { PropertySearch ps = (PropertySearch) JsonUtils.decode(val, new TypeToken<PropertySearch>() {}.getType()); if (op.equals("mk")) { modelSearch.getProperties().remove(ps); modelSearch.getProperties().add(ps); } else if (op.equals("rm")) { modelSearch.getProperties().remove(ps); } else if (op.equals("cl")) { modelSearch.getProperties().clear(); } } if (key.equals("order")) { try { modelSearch.setOrderBy(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("page")) { try { modelSearch.setPageIndex(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } } } return UrlUtils.modelBrowseUrl(modelSearch, name); }
public static String browseUrl(ItemSearch sourceItemSearch, String name, String strChange) { ItemSearch itemSearch; try { itemSearch = (ItemSearch) BeanUtils.cloneBean(sourceItemSearch); itemSearch.setManufacturerIds(new ArrayList<>(sourceItemSearch.getManufacturerIds())); itemSearch.setModelIds(new ArrayList<>(sourceItemSearch.getModelIds())); itemSearch.setCityIds(new ArrayList<>(sourceItemSearch.getCityIds())); itemSearch.setProperties(new ArrayList<>(sourceItemSearch.getProperties())); } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException ex) { itemSearch = new ItemSearch(); } if (strChange != null && !strChange.equals("")) { List<Map<String, String>> changes = (List<Map<String, String>>) JsonUtils.decode(strChange, new TypeToken<List<Map<String, String>>>() {}.getType()); for (Map<String, String> ch : changes) { String op = ch.get("op"); String key = ch.get("key"); String val = ch.get("val"); if (key.equals("cid")) { if (op.equals("mk")) { itemSearch.setCategoryIds(new ArrayList<String>()); itemSearch.getCategoryIds().add(val); } else if (op.equals("rm")) { itemSearch.setCategoryIds(null); itemSearch.setCategoryId(null); } } if (key.equals("keyword")) { if (op.equals("mk")) { itemSearch.setKeyword(val); } else if (op.equals("rm")) { itemSearch.setKeyword(null); } } if (key.equals("sellerId")) { if (op.equals("mk")) { itemSearch.setSellerId(val); } else if (op.equals("rm")) { itemSearch.setSellerId(null); } } if (key.equals("manufacturers")) { if (op.equals("mk")) { itemSearch.getManufacturerIds().remove(val); itemSearch.getManufacturerIds().add(val); } else if (op.equals("rm")) { itemSearch.getManufacturerIds().remove(val); } else if (op.equals("cl")) { itemSearch.getManufacturerIds().clear(); } } if (key.equals("models")) { if (op.equals("mk")) { itemSearch.getModelIds().remove(val); itemSearch.getModelIds().add(val); } else if (op.equals("rm")) { itemSearch.getModelIds().remove(val); } else if (op.equals("cl")) { itemSearch.getModelIds().clear(); } } if (key.equals("cities")) { if (op.equals("mk")) { itemSearch.getCityIds().remove(val); itemSearch.getCityIds().add(val); } else if (op.equals("rm")) { itemSearch.getCityIds().remove(val); } else if (op.equals("cl")) { itemSearch.getCityIds().clear(); } } if (key.equals("properties")) { PropertySearch ps = (PropertySearch) JsonUtils.decode(val, new TypeToken<PropertySearch>() {}.getType()); if (op.equals("mk")) { itemSearch.getProperties().remove(ps); itemSearch.getProperties().add(ps); } else if (op.equals("rm")) { itemSearch.getProperties().remove(ps); } else if (op.equals("cl")) { itemSearch.getProperties().clear(); } } if (key.equals("freeship")) { if (op.equals("mk")) { itemSearch.setFreeShip(true); } else if (op.equals("rm")) { itemSearch.setFreeShip(false); } } if (key.equals("cod")) { if (op.equals("mk")) { itemSearch.setCod(true); } else if (op.equals("rm")) { itemSearch.setCod(false); } } if (key.equals("onlinepayment")) { if (op.equals("mk")) { itemSearch.setOnlinePayment(true); } else if (op.equals("rm")) { itemSearch.setOnlinePayment(false); } } if (key.equals("promotion")) { if (op.equals("mk")) { itemSearch.setPromotion(true); } else if (op.equals("rm")) { itemSearch.setPromotion(false); } } if (key.equals("promotionId")) { if (op.equals("mk")) { itemSearch.setPromotionId(val); } else if (op.equals("rm")) { itemSearch.setPromotionId(null); } } if (key.equals("type")) { try { if (val.equals("BUYNOW")) { itemSearch.setListingType(ListingType.BUYNOW); } else if (val.equals("AUCTION")) { itemSearch.setListingType(ListingType.AUCTION); } else { itemSearch.setListingType(null); } } catch (NumberFormatException ex) { } } if (key.equals("condition")) { try { if (val.equals("NEW")) { itemSearch.setCondition(Condition.NEW); } else if (val.equals("OLD")) { itemSearch.setCondition(Condition.OLD); } else { itemSearch.setCondition(null); } } catch (NumberFormatException ex) { } } if (key.equals("pricefrom")) { try { itemSearch.setPriceFrom(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("priceto")) { try { itemSearch.setPriceTo(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("order")) { try { itemSearch.setOrderBy(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } if (key.equals("page")) { try { itemSearch.setPageIndex(Integer.parseInt(val)); } catch (NumberFormatException ex) { } } } } return UrlUtils.browseUrl(itemSearch, name); }