下面列出了org.apache.commons.lang3.StringUtils#isNotEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void referenceChanged(ReferenceEvent<String> e)
{
if (e.getSource() == nameRef)
{
if (StringUtils.isEmpty(tabNameRef.get()))
{
titleLabel.setText(e.getNewReference());
}
}
else
{
if (StringUtils.isNotEmpty(e.getNewReference()))
{
titleLabel.setText(e.getNewReference());
}
else
{
titleLabel.setText(nameRef.get());
}
}
}
protected void createItemDefinitions(BpmnModel bpmnModel) {
for (org.flowable.bpmn.model.ItemDefinition itemDefinitionElement : bpmnModel.getItemDefinitions().values()) {
if (!itemDefinitionMap.containsKey(itemDefinitionElement.getId())) {
StructureDefinition structure = null;
try {
// it is a class
Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
structure = new ClassStructureDefinition(classStructure);
} catch (FlowableException e) {
// it is a reference to a different structure
structure = structureDefinitionMap.get(itemDefinitionElement.getStructureRef());
}
ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
}
itemDefinitionMap.put(itemDefinition.getId(), itemDefinition);
}
}
}
private void ifTaskIdentitiesEmptyForceToCreatorOrMaintenance(AeiObjects aeiObjects, Manual manual,
TaskIdentities taskIdentities) throws Exception {
if (taskIdentities.isEmpty()) {
String identity = aeiObjects.business().organization().identity()
.get(aeiObjects.getWork().getCreatorIdentity());
if (StringUtils.isNotEmpty(identity)) {
logger.info("{}[{}]未能找到指定的处理人, 标题:{}, id:{}, 强制指定处理人为活动的创建身份:{}.", aeiObjects.getProcess().getName(),
manual.getName(), aeiObjects.getWork().getTitle(), aeiObjects.getWork().getId(), identity);
taskIdentities.addIdentity(identity);
} else {
identity = aeiObjects.business().organization().identity()
.get(Config.processPlatform().getMaintenanceIdentity());
if (StringUtils.isNotEmpty(identity)) {
logger.info("{}[{}]未能找到指定的处理人, 也没有能找到工作创建人, 标题:{}, id:{}, 强制指定处理人为系统维护身份:{}.",
aeiObjects.getProcess().getName(), manual.getName(), aeiObjects.getWork().getTitle(),
aeiObjects.getWork().getId(), identity);
taskIdentities.addIdentity(identity);
} else {
throw new ExceptionExpectedEmpty(aeiObjects.getWork().getTitle(), aeiObjects.getWork().getId(),
aeiObjects.getActivity().getName(), aeiObjects.getActivity().getId());
}
}
}
}
/**
* Converts string representation of XML into Document
*
* @param str
* String representation of XML
* @return DOM object
* @throws IOException
* I/O exception
*/
public static Document stringToDoc(String str) throws IOException {
if (StringUtils.isNotEmpty(str)) {
try (Reader reader = new StringReader(str)) {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.parse(new InputSource(reader));
return doc;
} catch (Exception ex) {
log.debug("String: {}", str);
throw new IOException(String.format("Error converting from string to doc %s", ex.getMessage()));
}
} else {
throw new IOException("Error - could not convert empty string to doc");
}
}
@RequestMapping(value = "/{groupId}/users", method = RequestMethod.GET)
public ResultListDataRepresentation getGroupUsers(@PathVariable String groupId, @RequestParam(required = false) String filter, @RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize) {
validateAdminRole();
int pageValue = page != null ? page.intValue() : 0;
int pageSizeValue = pageSize != null ? pageSize.intValue() : 50;
UserQuery userQuery = identityService.createUserQuery().memberOfGroup(groupId);
if (StringUtils.isNotEmpty(filter)) {
userQuery.userFullNameLike("%" + filter + "%");
}
List<User> users = userQuery.listPage(pageValue, pageSizeValue);
List<UserRepresentation> userRepresentations = new ArrayList<UserRepresentation>(users.size());
for (User user : users) {
userRepresentations.add(new UserRepresentation(user));
}
ResultListDataRepresentation resultListDataRepresentation = new ResultListDataRepresentation(userRepresentations);
resultListDataRepresentation.setStart(pageValue * pageSizeValue);
resultListDataRepresentation.setSize(userRepresentations.size());
resultListDataRepresentation.setTotal(userQuery.count());
return resultListDataRepresentation;
}
private FileInfo concreteAttachment(StorageMapping mapping, Document document, String name, EffectivePerson effectivePerson, String site) throws Exception {
FileInfo attachment = new FileInfo();
String fileName = UUID.randomUUID().toString();
String extension = FilenameUtils.getExtension( name );
if ( StringUtils.isNotEmpty(extension)) {
fileName = fileName + "." + extension;
}else{
throw new Exception("file extension is empty.");
}
if( name.indexOf( "\\" ) >0 ){
name = StringUtils.substringAfterLast( name, "\\");
}
if( name.indexOf( "/" ) >0 ){
name = StringUtils.substringAfterLast( name, "/");
}
attachment.setCreateTime( new Date() );
attachment.setLastUpdateTime( new Date() );
attachment.setExtension( extension );
attachment.setName( name );
attachment.setFileName( fileName );
attachment.setStorage( mapping.getName() );
attachment.setAppId( document.getAppId() );
attachment.setCategoryId( document.getCategoryId() );
attachment.setDocumentId( document.getId() );
attachment.setCreatorUid( effectivePerson.getDistinguishedName() );
attachment.setSite( site );
attachment.setFileHost( "" );
attachment.setFileType("ATTACHMENT");
attachment.setFileExtType( getExtType( extension ) );
attachment.setFilePath( "" );
return attachment;
}
/**
* 判断是否为普通管理员
*
* @param siteUserId
* @return
*/
public static boolean isSiteManager(String siteUserId) {
if (isSiteSuperAdmin(siteUserId)) {
return true;
}
if (siteManagerSet != null && StringUtils.isNotEmpty(siteUserId)) {
return siteManagerSet.contains(siteUserId);
}
return false;
}
/**
* Processing clean cache event
*
* @param cacheKey the key to clean on cache
*/
public void processCleanCacheEvent(ContentCacheKey cacheKey, Boolean isPartialKey) {
if (cacheKey != null && StringUtils.isNotEmpty(cacheKey.getKey())) {
if (isPartialKey) {
cache.evictMatch(cacheKey);
} else {
cache.evict(cacheKey);
}
LOGGER.info("Deleting content cache key {} with partial match {}", cacheKey.getKey(), isPartialKey);
} else {
LOGGER.warn("Deleting all cache because we don't have key");
cache.clear();
}
}
static void createPath(ZooKeeper zk, String path, CreateMode createMode, List<ACL> acl) throws Exception {
String[] list = path.split("/");
String zkPath = "";
for (String str : list) {
if (StringUtils.isNotEmpty(str)) {
zkPath = zkPath + "/" + str;
if (zk.exists(zkPath, false) == null) {
zk.create(zkPath, null, acl, createMode);
}
}
}
}
public String escapeHtml(String value, boolean escapeNewlines) {
/*
* Velocity tools depend on this returning empty string (and never null),
* they also depend on this handling a null input and converting it to null
*/
String val = "";
if (StringUtils.isNotEmpty(value)){
val = StringEscapeUtils.escapeHtml4(value);
if (escapeNewlines && val != null) {
val = val.replace("\n", "<br/>\n");
}
}
return val;
}
public static SQL WHERE_CUSTOM(SQL sql, Class modelClass, Map<String, Object> dataMap, List<CustomQueryParam> customQueryParams, String tableAlias) {
Map<String, Property> properties = ModelUtils.getProperties(modelClass, null);
// int i = 0;
for (CustomQueryParam customQueryParam : customQueryParams) {
String key = customQueryParam.getProperty();
Property property = properties.get(key);
if (property == null) {
continue;
}
String condition = "";
if (StringUtils.isNotEmpty(tableAlias)) {
condition = tableAlias + "." + condition;
}
if (customQueryParam instanceof WithValueQueryParam) {
WithValueQueryParam withValueQueryParam = (WithValueQueryParam) customQueryParam;
dataMap.put(dataMap.size() + "", withValueQueryParam.getValue());
// 不能以property为key放入dataMap,因为可能有相同的property,如> & <
condition = condition + property.getColumnName() + " " + withValueQueryParam.getOperator() + " #{" + (dataMap.size() - 1) + "}";
// i++;
} else if (customQueryParam instanceof NoValueQueryParam) {
NoValueQueryParam noValueQueryParam = (NoValueQueryParam) customQueryParam;
condition = condition + property.getColumnName() + " " + noValueQueryParam.getCondition();
}
sql.WHERE(condition);
}
return sql;
}
public void process_table_OKR_WORK_REPORT_PROCESSLOG() throws Exception {
List<String> all_entity_ids = null;
Business business = null;
String old_name = null;
OkrWorkReportProcessLog entity = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
business = new Business(emc);
all_entity_ids = business.okrWorkReportProcessLogFactory().listAll();
if( ListTools.isNotEmpty(all_entity_ids )) {
emc.beginTransaction( OkrWorkReportProcessLog.class );
for( String _id : all_entity_ids ) {
entity = emc.find( _id, OkrWorkReportProcessLog.class );
if( entity != null ) {
old_name = entity.getProcessorIdentity();
if( StringUtils.isNotEmpty(old_name) && UpdateIdentityMap.getIdentityWithOldName( old_name ) != null ) {
entity.setProcessorIdentity( UpdateIdentityMap.getIdentityWithOldName(old_name));
}
old_name = entity.getProcessorName();
if( StringUtils.isNotEmpty(old_name) && UpdatePersonMap.getPersonWithOldName( old_name ) != null ) {
entity.setProcessorName( UpdatePersonMap.getPersonWithOldName(old_name));
}
old_name = entity.getProcessorTopUnitName();
if( StringUtils.isNotEmpty(old_name) && UpdateUnitMap.getUnitWithOldName( old_name ) != null ) {
entity.setProcessorTopUnitName( UpdateUnitMap.getUnitWithOldName(old_name));
}
old_name = entity.getProcessorUnitName();
if( StringUtils.isNotEmpty(old_name) && UpdateUnitMap.getUnitWithOldName( old_name ) != null ) {
entity.setProcessorUnitName( UpdateUnitMap.getUnitWithOldName(old_name));
}
}
}
emc.commit();
}
}catch( Exception e ){
throw e;
}
}
@Override
protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception {
ValuedDataObject dataObject = (ValuedDataObject) element;
if (StringUtils.isNotEmpty(dataObject.getId()) && dataObject.getValue() != null) {
if (!didWriteExtensionStartElement) {
xtw.writeStartElement(ELEMENT_EXTENSIONS);
didWriteExtensionStartElement = true;
}
xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_DATA_VALUE, FLOWABLE_EXTENSIONS_NAMESPACE);
if (dataObject.getValue() != null) {
String value = null;
if (dataObject instanceof DateDataObject) {
value = sdf.format(dataObject.getValue());
} else {
value = dataObject.getValue().toString();
}
if (dataObject instanceof StringDataObject && xmlChars.matcher(value).find()) {
xtw.writeCData(value);
} else {
xtw.writeCharacters(value);
}
}
xtw.writeEndElement();
}
return didWriteExtensionStartElement;
}
private Response getExportResponse(String preparationId, String datasetId, String stepId, String csvDelimiter,
String fileName, Integer expectedStatus) {
RequestSpecification exportRequest = given() //
.formParam("exportType", "CSV") //
.formParam(ExportFormat.PREFIX + CSVFormat.ParametersCSV.ENCLOSURE_MODE, //
CSVFormat.ParametersCSV.ENCLOSURE_ALL_FIELDS) //
.formParam("preparationId", preparationId) //
.formParam("stepId", stepId);
if (datasetId != null) {
exportRequest.formParam("datasetId", datasetId);
}
if (StringUtils.isNotEmpty(csvDelimiter)) {
exportRequest.formParam(ExportFormat.PREFIX + CSVFormat.ParametersCSV.FIELDS_DELIMITER, csvDelimiter);
}
if (StringUtils.isNotEmpty(fileName)) {
exportRequest.formParam(ExportFormat.PREFIX + "fileName", fileName);
}
if (expectedStatus != null) {
exportRequest //
.when() //
.expect() //
.statusCode(expectedStatus) //
.log() //
.ifError();
}
return exportRequest.get("/api/export");
}
/**
* 新增产品处理(保存到数据库)
*/
@RequestMapping("/doadd")
public String doadd(SimpleProduct product, RedirectAttributes attr, String id) {
try {
Product p = null;
String msg = null;
Product cp = productService.loadByCode(product.getCode());
if (StringUtils.isNotEmpty(id)) {
p = productService.loadById(id);
if (cp != null && !cp.getId().equals(p.getId())) {
attr.addFlashAttribute("msg", "该产品已存在,无法继续添加");
return "redirect:/product/add";
}
msg = "修改产品成功";
} else {
if (cp != null) {
attr.addFlashAttribute("msg", "该产品已存在,无法继续添加");
return "redirect:/product/add";
}
msg = "添加产品成功";
p = new Product();
p.setStatus(Product.Status.VALID);
//设置产品月缴管理费
setProductMonthFee(p);
}
productService.editProduct(p, product);
attr.addFlashAttribute("msg", msg);
return "redirect:/product/index";
} catch (Exception e) {
Logger.error("新增产品异常", e);
if (StringUtils.isNotEmpty(id)) {
attr.addFlashAttribute("msg", "修改产品失败");
return "redirect:/product/detail/" + id;
} else {
attr.addFlashAttribute("msg", "添加产品失败");
return "redirect:/product/add";
}
}
}
@Override
public ReviveModelResultRepresentation reviveProcessModelHistory(ModelHistory modelHistory, User user, String newVersionComment) {
Model latestModel = modelRepository.get(modelHistory.getModelId());
if (latestModel == null) {
throw new IllegalArgumentException("No process model found with id: " + modelHistory.getModelId());
}
// Store the current model in history
ModelHistory latestModelHistory = createNewModelhistory(latestModel);
persistModelHistory(latestModelHistory);
// Populate the actual latest version with the properties in the historic model
latestModel.setVersion(latestModel.getVersion() + 1);
latestModel.setLastUpdated(new Date());
latestModel.setLastUpdatedBy(user.getId());
latestModel.setName(modelHistory.getName());
latestModel.setKey(modelHistory.getKey());
latestModel.setDescription(modelHistory.getDescription());
latestModel.setModelEditorJson(modelHistory.getModelEditorJson());
latestModel.setModelType(modelHistory.getModelType());
latestModel.setComment(newVersionComment);
persistModel(latestModel);
ReviveModelResultRepresentation result = new ReviveModelResultRepresentation();
// For apps, we need to make sure the referenced processes exist as models.
// It could be the user has deleted the process model in the meantime. We give back that info to the user.
if (latestModel.getModelType() == AbstractModel.MODEL_TYPE_APP) {
if (StringUtils.isNotEmpty(latestModel.getModelEditorJson())) {
try {
AppDefinition appDefinition = objectMapper.readValue(latestModel.getModelEditorJson(), AppDefinition.class);
for (AppModelDefinition appModelDefinition : appDefinition.getModels()) {
if (modelRepository.get(appModelDefinition.getId()) == null) {
result.getUnresolvedModels().add(new UnresolveModelRepresentation(appModelDefinition.getId(),
appModelDefinition.getName(), appModelDefinition.getLastUpdatedBy()));
}
}
} catch (Exception e) {
LOGGER.error("Could not deserialize app model json (id = {})", latestModel.getId(), e);
}
}
}
return result;
}
@Override
public void execute(DelegateExecution execution) {
Object value = null;
try {
CommandContext commandContext = CommandContextUtil.getCommandContext();
String skipExpressionText = null;
if (skipExpression != null) {
skipExpressionText = skipExpression.getExpressionText();
}
boolean isSkipExpressionEnabled = SkipExpressionUtil.isSkipExpressionEnabled(skipExpressionText, serviceTaskId, execution, commandContext);
if (!isSkipExpressionEnabled || !SkipExpressionUtil.shouldSkipFlowElement(skipExpressionText, serviceTaskId, execution, commandContext)) {
if (CommandContextUtil.getProcessEngineConfiguration(commandContext).isEnableProcessDefinitionInfoCache()) {
ObjectNode taskElementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(serviceTaskId, execution.getProcessDefinitionId());
if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION)) {
String overrideExpression = taskElementProperties.get(DynamicBpmnConstants.SERVICE_TASK_EXPRESSION).asText();
if (StringUtils.isNotEmpty(overrideExpression) && !overrideExpression.equals(expression.getExpressionText())) {
expression = CommandContextUtil.getProcessEngineConfiguration(commandContext).getExpressionManager().createExpression(overrideExpression);
}
}
}
value = expression.getValue(execution);
if (resultVariable != null) {
if (storeResultVariableAsTransient) {
if (useLocalScopeForResultVariable) {
execution.setTransientVariableLocal(resultVariable, value);
} else {
execution.setTransientVariable(resultVariable, value);
}
} else {
if (useLocalScopeForResultVariable) {
execution.setVariableLocal(resultVariable, value);
} else {
execution.setVariable(resultVariable, value);
}
}
}
}
if (!this.triggerable) {
leave(execution);
}
} catch (Exception exc) {
Throwable cause = exc;
BpmnError error = null;
while (cause != null) {
if (cause instanceof BpmnError) {
error = (BpmnError) cause;
break;
} else if (cause instanceof RuntimeException) {
if (ErrorPropagation.mapException((RuntimeException) cause, (ExecutionEntity) execution, mapExceptions)) {
return;
}
}
cause = cause.getCause();
}
if (error != null) {
ErrorPropagation.propagateError(error, execution);
} else {
throw exc;
}
}
}
public TopicReportResponse getTopicReport(TopicGetListRequest topicGetListRequest) {
lastAccessTime = System.currentTimeMillis();
int page = Integer.parseInt(topicGetListRequest.getPage());
int pageSize = Integer.parseInt(topicGetListRequest.getLimit());
List<TopicVo> topicVoList = new ArrayList<>();
Map<String, List<ConsumerGroupTopicEntity>> topicSubscribeMap = consumerGroupTopicService
.getTopicSubscribeMap();
for (TopicVo topicVo : topicVoListRf.get()) {
if (StringUtils.isNotEmpty(topicGetListRequest.getName())) {
if (!topicGetListRequest.getName().equals(topicVo.getName())) {
continue;
}
}
if (StringUtils.isNotEmpty(topicGetListRequest.getTopicExceptionType())) {
// 过滤掉非僵尸topic
if ("1".equals(topicGetListRequest.getTopicExceptionType())) {
if (topicVo.getMsgCount() > 0) {// 过滤有消息的topic
continue;
}
if (topicSubscribeMap.containsKey(topicVo.getOriginName())) {// 过滤已经被订阅的topic
continue;
}
//排除创建时间不到三天的topic
if (System.currentTimeMillis()-topicVo.getInsertTime().getTime() < 3 * 24 * 60 * 60
* 1000) {
continue;
}
}
// 过滤掉负责人正常的topic
if ("2".equals(topicGetListRequest.getTopicExceptionType())) {
List<String> ownerIds = Arrays.asList(topicVo.getOwnerIds().split(","));
if (uiQueueOffsetService.isOwnerAvailable(ownerIds)) {
continue;
}
}
//过滤掉已经被订阅的topic
if("3".equals(topicGetListRequest.getTopicExceptionType())){
if (topicSubscribeMap.containsKey(topicVo.getOriginName())) {// 过滤已经被订阅的topic
continue;
}
}
}
if (StringUtils.isNotEmpty(topicGetListRequest.getQueueManagementType())) {
if ("1".equals(topicGetListRequest.getQueueManagementType())) {
if (!shouldShrink.equals(topicVo.getIsReasonable())) {
continue;
}
}
if ("2".equals(topicGetListRequest.getQueueManagementType())) {
if (!shouldExpand.equals(topicVo.getIsReasonable())) {
continue;
}
}
}
topicVoList.add(topicVo);
}
int t = topicVoList.size();
if ((page * pageSize) > topicVoList.size()) {
topicVoList = topicVoList.subList((page - 1) * pageSize, topicVoList.size());
} else {
topicVoList = topicVoList.subList((page - 1) * pageSize, page * pageSize);
}
return new TopicReportResponse(new Long(t), topicVoList);
}
public void setTradingDay(String tradingDay) {
if (StringUtils.isNotEmpty(tradingDay)) {
System.arraycopy(tradingDay.getBytes(), 0, this.tradingDay, 0, tradingDay.getBytes().length);
}
}
private static void useCsrfToken() {
if (StringUtils.isNotEmpty(csrfToken)) {
client.addHeader("X-CSRF-Token", csrfToken);
}
}