List of usage examples for org.apache.commons.lang3 StringUtils equals
public static boolean equals(final CharSequence cs1, final CharSequence cs2)
Compares two CharSequences, returning true if they represent equal sequences of characters.
null s are handled without exceptions.
From source file:de.micromata.genome.gwiki.pagelifecycle_1_0.auth.PlcSimpleUserAuthorization.java
/** * @param ctx//from w ww . j a v a 2s . c o m * @param ei * @return * @see de.micromata.genome.gwiki.model.GWikiAuthorization#isAllowToEdit(de.micromata.genome.gwiki.page.GWikiContext, * de.micromata.genome.gwiki.model.GWikiElementInfo) */ public boolean isAllowToEdit(final GWikiContext ctx, final GWikiElementInfo ei) { if (isAllowTo(ctx, GWikiAuthorizationRights.GWIKI_ADMIN.name()) == true) { return true; } if (super.isAllowTo(ctx, GWikiPlcRights.PLC_EDIT_ARTICLE.name()) && ei != null) { boolean hasFileStatItem = ctx.runInTenantContext(ctx.getWikiWeb().getTenantId(), getWikiSelector(ctx), new CallableX<Boolean, RuntimeException>() { public Boolean call() throws RuntimeException { BranchFileStats stats = PlcUtils.getBranchFileStats(ctx); if (stats != null) { FileStatsDO statsForId = stats.getFileStatsForId(ei.getId()); if (statsForId == null) { return false; } else { return true; } } return false; } }); // Element has a branchFileStatEntry. Use the own authorization method. if (hasFileStatItem) { return ctx.runInTenantContext(ctx.getWikiWeb().getTenantId(), getWikiSelector(ctx), new CallableX<Boolean, RuntimeException>() { public Boolean call() throws RuntimeException { BranchFileStats stats = PlcUtils.getBranchFileStats(ctx); FileStatsDO statsForId = stats.getFileStatsForId(ei.getId()); if (StringUtils.equals(statsForId.getAssignedTo(), ctx.getWikiWeb().getAuthorization().getCurrentUserName(ctx))) { return true; } return false; } }); } } return super.isAllowToEdit(ctx, ei); }
From source file:com.glaf.activiti.delegate.CancelAllTask.java
@Override public void execute(ActivityExecution execution) throws Exception { logger.debug("----------------------------------------------------"); logger.debug("------------------CancelAllTask---------------------"); logger.debug("----------------------------------------------------"); boolean executable = true; if (conditionExpression != null) { Object value = conditionExpression.getValue(execution); if (value != null) { logger.debug("condition:" + value); if (value instanceof Boolean) { Boolean b = (Boolean) value; executable = b.booleanValue(); }//from ww w. j a va 2 s. co m } } if (!executable) { logger.debug("???false??"); return; } String processInstanceId = execution.getProcessInstanceId(); CommandContext commandContext = Context.getCommandContext(); TaskQueryImpl taskQuery = new TaskQueryImpl(); taskQuery.processInstanceId(processInstanceId); Page page = new Page(0, 10000); taskQuery.setFirstResult(page.getFirstResult()); taskQuery.setMaxResults(page.getMaxResults()); List<Task> tasks = commandContext.getTaskEntityManager().findTasksByQueryCriteria(taskQuery); if (tasks != null && !tasks.isEmpty()) { if (includes != null && includes.getValue(execution) != null) { String x_includes = (String) includes.getValue(execution); logger.debug("includes:" + x_includes); if (StringUtils.isNotEmpty(x_includes)) { if (StringUtils.equals(x_includes, "ALL")) { } else { List<String> list = StringTools.split(x_includes); for (String taskDefKey : list) { for (Task task : tasks) { if (StringUtils.equals(task.getTaskDefinitionKey(), taskDefKey)) { } } } } } } } String name = null; if (outcomeVar != null) { name = (String) outcomeVar.getValue(execution); } if (name == null) { name = Constants.OUTCOME; } String outcome = (String) execution.getVariable(name); if (outcome != null) { PvmTransition transition = execution.getActivity().findOutgoingTransition(outcome); if (transition != null) { execution.take(transition); } } else { PvmTransition defaultOutgoingTransition = execution.getActivity().getOutgoingTransitions().get(0); execution.take(defaultOutgoingTransition); } }
From source file:com.glaf.core.service.impl.MxSysDataItemServiceImpl.java
@SuppressWarnings("unchecked") public JSONArray getJsonData(long id, Map<String, Object> parameter) { JSONArray result = new JSONArray(); SysDataItem sysDataItem = this.getSysDataItemById(id); if (sysDataItem != null) { String cacheKey = "sys_dataitem_data_" + id; if (StringUtils.equals("Y", sysDataItem.getCacheFlag())) { String text = CacheFactory.getString(cacheKey); if (StringUtils.isNotEmpty(text)) { try { result = JSON.parseArray(text); return result; } catch (Exception ex) { // Ignore error }/*from w ww .j a v a 2s.c o m*/ } } if (StringUtils.isNotEmpty(sysDataItem.getQueryId())) { List<Object> list = sqlSessionTemplate.selectList(sysDataItem.getQueryId(), parameter); if (list != null && !list.isEmpty()) { Map<String, Object> newDataMap = new CaseInsensitiveHashMap(); for (Object object : list) { newDataMap.clear(); JSONObject json = new JSONObject(); if (object instanceof Map) { Map<String, Object> dataMap = (Map<String, Object>) object; Iterator<Entry<String, Object>> iterator = dataMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String name = entry.getKey(); Object value = entry.getValue(); newDataMap.put(name, value); newDataMap.put(name.toLowerCase(), value); json.put(name, value); } } else { Map<String, Object> dataMap = Tools.getDataMap(object); Iterator<Entry<String, Object>> iterator = dataMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String name = entry.getKey(); Object value = entry.getValue(); newDataMap.put(name, value); newDataMap.put(name.toLowerCase(), value); json.put(name, value); } } if (StringUtils.isNotEmpty(sysDataItem.getTextField())) { json.put("text", newDataMap.get(sysDataItem.getTextField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getValueField())) { json.put("value", newDataMap.get(sysDataItem.getValueField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeIdField())) { json.put("id", newDataMap.get(sysDataItem.getTreeIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeParentIdField())) { json.put("parentId", newDataMap.get(sysDataItem.getTreeParentIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeNameField())) { json.put("name", newDataMap.get(sysDataItem.getTreeNameField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeTreeIdField())) { json.put("treeId", newDataMap.get(sysDataItem.getTreeTreeIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeListNoField())) { json.put("listno", newDataMap.get(sysDataItem.getTreeListNoField().toLowerCase())); } result.add(json); } } } else if (StringUtils.isNotEmpty(sysDataItem.getQuerySQL())) { if (!DBUtils.isLegalQuerySql(sysDataItem.getQuerySQL())) { throw new RuntimeException(" SQL statement illegal "); } Map<String, Object> params = new HashMap<String, Object>(); params.put("queryString", sysDataItem.getQuerySQL()); params.put("parameter", parameter); List<Map<String, Object>> list = tablePageMapper.getSqlQueryList(params); if (list != null && !list.isEmpty()) { Map<String, Object> newDataMap = new CaseInsensitiveHashMap(); for (Map<String, Object> dataMap : list) { newDataMap.clear(); JSONObject json = new JSONObject(); Iterator<Entry<String, Object>> iterator = dataMap.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String name = entry.getKey(); Object value = entry.getValue(); newDataMap.put(name, value); newDataMap.put(name.toLowerCase(), value); json.put(name, value); } if (StringUtils.isNotEmpty(sysDataItem.getTextField())) { json.put("text", newDataMap.get(sysDataItem.getTextField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getValueField())) { json.put("value", newDataMap.get(sysDataItem.getValueField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeIdField())) { json.put("id", newDataMap.get(sysDataItem.getTreeIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeParentIdField())) { json.put("parentId", newDataMap.get(sysDataItem.getTreeParentIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeNameField())) { json.put("name", newDataMap.get(sysDataItem.getTreeNameField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeTreeIdField())) { json.put("treeId", newDataMap.get(sysDataItem.getTreeTreeIdField().toLowerCase())); } if (StringUtils.isNotEmpty(sysDataItem.getTreeListNoField())) { json.put("listno", newDataMap.get(sysDataItem.getTreeListNoField().toLowerCase())); } result.add(json); } } } if (StringUtils.equals("Y", sysDataItem.getCacheFlag())) { if (!result.isEmpty()) { CacheFactory.put(cacheKey, result.toJSONString()); } } } return result; }
From source file:com.glaf.generator.tools.JPAEntityToXmlMapping.java
public ClassDefinition convert(String className) throws Exception { ClassDefinition classDefinition = new TableDefinition(); String simpleName = className; String packageName = ""; if (className.indexOf(".") != -1) { simpleName = className.substring(className.lastIndexOf(".") + 1, className.length()); packageName = className.substring(0, className.lastIndexOf(".")); packageName = packageName.substring(0, packageName.lastIndexOf(".")); }/*from w ww . j a v a 2 s.com*/ classDefinition.setClassName(simpleName); classDefinition.setTitle(simpleName); classDefinition.setEnglishTitle(simpleName); classDefinition.setEntityName(simpleName); classDefinition.setPackageName(packageName); CtClass ctClass = pool.getCtClass(className); Object[] anns = ctClass.getAnnotations(); if (anns != null && anns.length > 0) { for (Object object : anns) { if (object instanceof javax.persistence.Table) { javax.persistence.Table table = (javax.persistence.Table) object; System.out.println(table.name()); classDefinition.setTableName(table.name()); } } } CtField[] fields = ctClass.getFields(); if (fields != null && fields.length > 0) { for (CtField field : fields) { boolean isPK = false; System.out.println(field.getName() + " " + field.getType().getName()); FieldDefinition fieldDefinition = new ColumnDefinition(); fieldDefinition.setTitle(StringTools.upper(field.getName())); fieldDefinition.setEditable(true); fieldDefinition.setEnglishTitle(StringTools.upper(field.getName())); fieldDefinition.setName(field.getName()); if (StringUtils.equals(field.getType().getName(), "java.lang.String")) { fieldDefinition.setType("String"); } else if (StringUtils.equals(field.getType().getName(), "java.util.Date")) { fieldDefinition.setType("Date"); } else if (StringUtils.equals(field.getType().getName(), "boolean") || StringUtils.equals(field.getType().getName(), "java.lang.Boolean")) { fieldDefinition.setType("Boolean"); } else if (StringUtils.equals(field.getType().getName(), "int") || StringUtils.equals(field.getType().getName(), "java.lang.Integer")) { fieldDefinition.setType("Integer"); } else if (StringUtils.equals(field.getType().getName(), "long") || StringUtils.equals(field.getType().getName(), "java.lang.Long")) { fieldDefinition.setType("Long"); } else if (StringUtils.equals(field.getType().getName(), "double") || StringUtils.equals(field.getType().getName(), "java.lang.Double")) { fieldDefinition.setType("Double"); } anns = field.getAnnotations(); if (anns != null && anns.length > 0) { for (Object object : anns) { if (object instanceof javax.persistence.Column) { javax.persistence.Column col = (javax.persistence.Column) object; fieldDefinition.setColumnName(col.name()); if (col.length() > 0) { fieldDefinition.setLength(col.length()); } fieldDefinition.setNullable(col.nullable()); fieldDefinition.setUpdatable(col.updatable()); fieldDefinition.setUnique(col.unique()); } if (object instanceof javax.persistence.Id) { isPK = true; fieldDefinition.setEditable(false); } } } if (fieldDefinition.getType() != null && fieldDefinition.getColumnName() != null) { if (isPK) { classDefinition.setIdField(fieldDefinition); } else { classDefinition.addField(fieldDefinition); } } } } CtMethod[] methods = ctClass.getMethods(); if (methods != null && methods.length > 0) { for (CtMethod method : methods) { if (method.getName().startsWith("get")) { boolean isPK = false; System.out.println("#######################"); String mm = method.getName().substring(3, method.getName().length()); String x_mm = StringTools.lower(mm); System.out.println(method.getName() + " " + method.getReturnType().getName()); FieldDefinition fieldDefinition = new ColumnDefinition(); fieldDefinition.setTitle(StringTools.upper(mm)); fieldDefinition.setEnglishTitle(StringTools.upper(mm)); fieldDefinition.setName(x_mm); fieldDefinition.setEditable(true); if (StringUtils.equals(method.getReturnType().getName(), "java.lang.String")) { fieldDefinition.setType("String"); } else if (StringUtils.equals(method.getReturnType().getName(), "java.util.Date")) { fieldDefinition.setType("Date"); } else if (StringUtils.equals(method.getReturnType().getName(), "boolean") || StringUtils.equals(method.getReturnType().getName(), "java.lang.Boolean")) { fieldDefinition.setType("Boolean"); } else if (StringUtils.equals(method.getReturnType().getName(), "int") || StringUtils.equals(method.getReturnType().getName(), "java.lang.Integer")) { fieldDefinition.setType("Integer"); } else if (StringUtils.equals(method.getReturnType().getName(), "long") || StringUtils.equals(method.getReturnType().getName(), "java.lang.Long")) { fieldDefinition.setType("Long"); } else if (StringUtils.equals(method.getReturnType().getName(), "double") || StringUtils.equals(method.getReturnType().getName(), "java.lang.Double")) { fieldDefinition.setType("Double"); } anns = method.getAnnotations(); if (anns != null && anns.length > 0) { System.out.println("---------------------"); for (Object object : anns) { if (object instanceof javax.persistence.Column) { javax.persistence.Column col = (javax.persistence.Column) object; System.out.println("col:" + col.name()); fieldDefinition.setColumnName(col.name()); System.out.println("col->:" + fieldDefinition.getColumnName()); if (col.length() > 0) { fieldDefinition.setLength(col.length()); } fieldDefinition.setNullable(col.nullable()); fieldDefinition.setUpdatable(col.updatable()); fieldDefinition.setUnique(col.unique()); } if (object instanceof javax.persistence.Id) { isPK = true; } } } if (fieldDefinition.getType() != null && fieldDefinition.getColumnName() != null) { if (isPK) { classDefinition.setIdField(fieldDefinition); } else { classDefinition.addField(fieldDefinition); } } } } } // System.out.println(classDefinition); return classDefinition; }
From source file:com.neophob.sematrix.generator.Textwriter.java
/** * create image./*w w w . ja va 2 s .co m*/ * * @param text the text */ public void createTextImage(String text) { //only load if needed if (StringUtils.equals(text, this.text)) { return; } this.text = text; BufferedImage img = new BufferedImage(TEXT_BUFFER_X_SIZE, internalBufferYSize, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = img.createGraphics(); FontRenderContext frc = g2.getFontRenderContext(); TextLayout layout = new TextLayout(text, font, frc); Rectangle2D rect = layout.getBounds(); int h = (int) (0.5f + rect.getHeight()); maxXPos = (int) (0.5f + rect.getWidth()) + 5; ypos = internalBufferYSize - (internalBufferYSize - h) / 2; img = new BufferedImage(maxXPos, internalBufferYSize, BufferedImage.TYPE_INT_RGB); g2 = img.createGraphics(); g2.setColor(color); g2.setFont(font); g2.setClip(0, 0, maxXPos, internalBufferYSize); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawString(text, xpos, ypos); DataBufferInt dbi = (DataBufferInt) img.getRaster().getDataBuffer(); textBuffer = dbi.getData(); g2.dispose(); wait = 0; xofs = 0; scrollRight = false; }
From source file:com.inkubator.hrm.web.personalia.BusinessTravelApprovalFormController.java
@PostConstruct @Override/* w ww. j a va 2 s .c om*/ public void initialization() { try { super.initialization(); String id = FacesUtil.getRequestParameter("execution"); /*selectedApprovalActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); isWaitingApproval = selectedApprovalActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), selectedApprovalActivity.getRequestBy());*/ currentActivity = approvalActivityService.getEntiyByPK(Long.parseLong(id.substring(1))); askingRevisedActivity = approvalActivityService.getEntityByActivityNumberAndSequence( currentActivity.getActivityNumber(), currentActivity.getSequence() - 1); isWaitingApproval = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_APPROVAL; isWaitingRevised = currentActivity.getApprovalStatus() == HRMConstant.APPROVAL_STATUS_WAITING_REVISED; isApprover = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getApprovedBy()); isRequester = StringUtils.equals(UserInfoUtil.getUserName(), currentActivity.getRequestBy()); Gson gson = JsonUtil.getHibernateEntityGsonBuilder().create(); JsonObject jsonObject = gson.fromJson(currentActivity.getPendingData(), JsonObject.class); businessTravelComponents = gson.fromJson(jsonObject.get("businessTravelComponents"), new TypeToken<List<BusinessTravelComponent>>() { }.getType()); selectedBusinessTravel = gson.fromJson(currentActivity.getPendingData(), BusinessTravel.class); EmpData empData = empDataService.getByIdWithDetail(selectedBusinessTravel.getEmpData().getId()); selectedBusinessTravel.setEmpData(empData); for (BusinessTravelComponent btc : businessTravelComponents) { totalAmount = totalAmount + btc.getPayByAmount(); } } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:com.glaf.mail.web.rest.MailTaskResource.java
@POST @Path("/delete") public void deleteById(@Context HttpServletRequest request, @Context UriInfo uriInfo) { String mailTaskId = request.getParameter("taskId"); if (StringUtils.isEmpty(mailTaskId)) { mailTaskId = request.getParameter("id"); }//from www . ja va 2s . c o m if (mailTaskId != null) { MailTask mailTask = mailTaskService.getMailTask(mailTaskId); if (mailTask != null && StringUtils.equals(mailTask.getCreateBy(), RequestUtils.getActorId(request))) { mailTaskService.deleteById(mailTaskId); } } else { throw new WebApplicationException(Response.Status.NOT_FOUND); } }
From source file:com.glaf.oa.budget.web.springmvc.BudgetViewController.java
@RequestMapping("/json") @ResponseBody/*from w ww . j a va 2 s .c o m*/ public byte[] json(HttpServletRequest request, ModelMap modelMap) throws IOException { LoginContext loginContext = RequestUtils.getLoginContext(request); Map<String, Object> params = RequestUtils.getParameterMap(request); BudgetQuery query = new BudgetQuery(); Tools.populate(query, params); query.setLoginContext(loginContext); query.setStatus(Integer.valueOf(2)); String gridType = ParamUtils.getString(params, "gridType"); if (gridType == null) { gridType = "easyui"; } int start = 0; int limit = 10; String orderName = null; String order = null; int pageNo = ParamUtils.getInt(params, "page"); limit = ParamUtils.getInt(params, "rows"); start = (pageNo - 1) * limit; orderName = ParamUtils.getString(params, "sortName"); order = ParamUtils.getString(params, "sortOrder"); if (start < 0) { start = 0; } if (limit <= 0) { limit = 20; } JSONObject result = new JSONObject(); int total = this.budgetService.getBudgetCountByQueryCriteria(query); if (total > 0) { result.put("total", Integer.valueOf(total)); result.put("totalCount", Integer.valueOf(total)); result.put("totalRecords", Integer.valueOf(total)); result.put("start", Integer.valueOf(start)); result.put("startIndex", Integer.valueOf(start)); result.put("limit", Integer.valueOf(limit)); result.put("pageSize", Integer.valueOf(limit)); if (StringUtils.isNotEmpty(orderName)) { query.setSortOrder(orderName); if (StringUtils.equals(order, "desc")) { query.setSortOrder(" desc "); } } List<Budget> list = this.budgetService.getBudgetsByQueryCriteria(start, limit, query); if ((list != null) && (!list.isEmpty())) { JSONArray rowsJSON = new JSONArray(); result.put("rows", rowsJSON); for (Budget budget : list) { JSONObject rowJSON = budget.toJsonObject(); rowJSON.put("id", budget.getBudgetid()); rowJSON.put("budgetId", budget.getBudgetid()); start++; rowJSON.put("startIndex", Integer.valueOf(start)); rowsJSON.add(rowJSON); } } } else { JSONArray rowsJSON = new JSONArray(); result.put("rows", rowsJSON); result.put("total", Integer.valueOf(total)); } return result.toJSONString().getBytes("UTF-8"); }
From source file:com.bekwam.resignator.NewPasswordController.java
private String validate() { if (StringUtils.isBlank(pfPassword.getText())) { return "Password cannot be blank."; }/*from ww w .ja v a 2 s . co m*/ if (StringUtils.length(pfPassword.getText()) < MIN_PASSWORD_LENGTH) { return "Password must be at least " + MIN_PASSWORD_LENGTH + " characters."; } if (StringUtils.isBlank(pfConfirmPassword.getText())) { return "Confirmation cannot be blank."; } if (!StringUtils.equals(pfPassword.getText(), pfConfirmPassword.getText())) { return "Passwords do not match"; } return ""; }
From source file:com.adguard.filter.http.HttpMethod.java
/** * Checks if response to this method could contain entity body. * For example HEAD does not expect response with body * * @param requestMethod Request method/* w ww.j a va2s. com*/ * @return true if expect */ public static boolean expectResponseEntityBody(String requestMethod) { return !StringUtils.equals(requestMethod, HEAD); }