From 468238c2eda059c586a370e9f826e2a3f7aef544 Mon Sep 17 00:00:00 2001 From: isunsine Date: Thu, 26 Apr 2018 21:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5Hutool=EF=BC=9B=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=A4=9A=E4=B8=AAFindBUG=E6=A3=80=E6=B5=8B=E5=87=BA?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rocessDefinitionDiagramLayoutResource.java | 1004 ++++++++--------- .../ProcessInstanceHighlightsResource.java | 510 ++++----- .../model/ModelEditorJsonRestResource.java | 142 +-- .../editor/model/ModelSaveRestResource.java | 207 ++-- .../java/com/len/base/BaseController.java | 124 +- .../main/java/com/len/base/CurrentMenu.java | 114 +- .../main/java/com/len/base/CurrentRole.java | 63 +- .../com/len/controller/MenuController.java | 233 ++-- .../shiro/RetryLimitCredentialsMatcher.java | 128 +-- .../com/len/service/impl/MenuServiceImpl.java | 418 +++---- .../len/service/impl/SysUserServiceImpl.java | 364 +++--- pom.xml | 708 ++++++------ 12 files changed, 2016 insertions(+), 1999 deletions(-) diff --git a/len-activiti/src/main/java/org/activiti/rest/diagram/services/BaseProcessDefinitionDiagramLayoutResource.java b/len-activiti/src/main/java/org/activiti/rest/diagram/services/BaseProcessDefinitionDiagramLayoutResource.java index 6c39db5..9aa28a3 100644 --- a/len-activiti/src/main/java/org/activiti/rest/diagram/services/BaseProcessDefinitionDiagramLayoutResource.java +++ b/len-activiti/src/main/java/org/activiti/rest/diagram/services/BaseProcessDefinitionDiagramLayoutResource.java @@ -1,502 +1,502 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.activiti.rest.diagram.services; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.ActivitiObjectNotFoundException; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior; -import org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior; -import org.activiti.engine.impl.bpmn.parser.BpmnParse; -import org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition; -import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration; -import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl; -import org.activiti.engine.impl.persistence.entity.ExecutionEntity; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.delegate.ActivityBehavior; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.impl.pvm.process.Lane; -import org.activiti.engine.impl.pvm.process.LaneSet; -import org.activiti.engine.impl.pvm.process.ParticipantProcess; -import org.activiti.engine.impl.pvm.process.TransitionImpl; -import org.activiti.engine.repository.ProcessDefinition; -import org.activiti.engine.runtime.Execution; -import org.activiti.engine.runtime.ProcessInstance; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; - -public class BaseProcessDefinitionDiagramLayoutResource { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private HistoryService historyService; - - public ObjectNode getDiagramNode(String processInstanceId, String processDefinitionId) { - - List highLightedFlows = Collections. emptyList(); - List highLightedActivities = Collections. emptyList(); - - Map subProcessInstanceMap = new HashMap(); - - ProcessInstance processInstance = null; - if (processInstanceId != null) { - processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - if (processInstance == null) { - throw new ActivitiObjectNotFoundException("Process instance could not be found"); - } - processDefinitionId = processInstance.getProcessDefinitionId(); - - List subProcessInstances = runtimeService - .createProcessInstanceQuery() - .superProcessInstanceId(processInstanceId).list(); - - for (ProcessInstance subProcessInstance : subProcessInstances) { - String subDefId = subProcessInstance.getProcessDefinitionId(); - - String superExecutionId = ((ExecutionEntity) subProcessInstance) - .getSuperExecutionId(); - ProcessDefinitionEntity subDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(subDefId); - - ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode(); - processInstanceJSON.put("processInstanceId", subProcessInstance.getId()); - processInstanceJSON.put("superExecutionId", superExecutionId); - processInstanceJSON.put("processDefinitionId", subDef.getId()); - processInstanceJSON.put("processDefinitionKey", subDef.getKey()); - processInstanceJSON.put("processDefinitionName", subDef.getName()); - - subProcessInstanceMap.put(superExecutionId, processInstanceJSON); - } - } - - if (processDefinitionId == null) { - throw new ActivitiObjectNotFoundException("No process definition id provided"); - } - - ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId); - - if (processDefinition == null) { - throw new ActivitiException("Process definition " + processDefinitionId + " could not be found"); - } - - ObjectNode responseJSON = new ObjectMapper().createObjectNode(); - - // Process definition - JsonNode pdrJSON = getProcessDefinitionResponse(processDefinition); - - if (pdrJSON != null) { - responseJSON.put("processDefinition", pdrJSON); - } - - // Highlighted activities - if (processInstance != null) { - ArrayNode activityArray = new ObjectMapper().createArrayNode(); - ArrayNode flowsArray = new ObjectMapper().createArrayNode(); - - highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - highLightedFlows = getHighLightedFlows(processInstanceId, processDefinition); - - for (String activityName : highLightedActivities) { - activityArray.add(activityName); - } - - for (String flow : highLightedFlows) - flowsArray.add(flow); - - responseJSON.put("highLightedActivities", activityArray); - responseJSON.put("highLightedFlows", flowsArray); - } - - // Pool shape, if process is participant in collaboration - if (processDefinition.getParticipantProcess() != null) { - ParticipantProcess pProc = processDefinition.getParticipantProcess(); - - ObjectNode participantProcessJSON = new ObjectMapper().createObjectNode(); - participantProcessJSON.put("id", pProc.getId()); - if (StringUtils.isNotEmpty(pProc.getName())) { - participantProcessJSON.put("name", pProc.getName()); - } else { - participantProcessJSON.put("name", ""); - } - participantProcessJSON.put("x", pProc.getX()); - participantProcessJSON.put("y", pProc.getY()); - participantProcessJSON.put("width", pProc.getWidth()); - participantProcessJSON.put("height", pProc.getHeight()); - - responseJSON.put("participantProcess", participantProcessJSON); - } - - // Draw lanes - - if (processDefinition.getLaneSets() != null && !processDefinition.getLaneSets().isEmpty()) { - ArrayNode laneSetArray = new ObjectMapper().createArrayNode(); - for (LaneSet laneSet : processDefinition.getLaneSets()) { - ArrayNode laneArray = new ObjectMapper().createArrayNode(); - if (laneSet.getLanes() != null && !laneSet.getLanes().isEmpty()) { - for (Lane lane : laneSet.getLanes()) { - ObjectNode laneJSON = new ObjectMapper().createObjectNode(); - laneJSON.put("id", lane.getId()); - if (StringUtils.isNotEmpty(lane.getName())) { - laneJSON.put("name", lane.getName()); - } else { - laneJSON.put("name", ""); - } - laneJSON.put("x", lane.getX()); - laneJSON.put("y", lane.getY()); - laneJSON.put("width", lane.getWidth()); - laneJSON.put("height", lane.getHeight()); - - List flowNodeIds = lane.getFlowNodeIds(); - ArrayNode flowNodeIdsArray = new ObjectMapper().createArrayNode(); - for (String flowNodeId : flowNodeIds) { - flowNodeIdsArray.add(flowNodeId); - } - laneJSON.put("flowNodeIds", flowNodeIdsArray); - - laneArray.add(laneJSON); - } - } - ObjectNode laneSetJSON = new ObjectMapper().createObjectNode(); - laneSetJSON.put("id", laneSet.getId()); - if (StringUtils.isNotEmpty(laneSet.getName())) { - laneSetJSON.put("name", laneSet.getName()); - } else { - laneSetJSON.put("name", ""); - } - laneSetJSON.put("lanes", laneArray); - - laneSetArray.add(laneSetJSON); - } - - if (laneSetArray.size() > 0) - responseJSON.put("laneSets", laneSetArray); - } - - ArrayNode sequenceFlowArray = new ObjectMapper().createArrayNode(); - ArrayNode activityArray = new ObjectMapper().createArrayNode(); - - // Activities and their sequence-flows - - for (ActivityImpl activity : processDefinition.getActivities()) { - getActivity(processInstanceId, activity, activityArray, sequenceFlowArray, - processInstance, highLightedFlows, subProcessInstanceMap); - } - - responseJSON.put("activities", activityArray); - responseJSON.put("sequenceFlows", sequenceFlowArray); - - return responseJSON; - } - - private List getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) { - - List highLightedFlows = new ArrayList(); - List historicActivityInstances = historyService - .createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - .orderByHistoricActivityInstanceStartTime().asc().list(); - - List historicActivityInstanceList = new ArrayList(); - for (HistoricActivityInstance hai : historicActivityInstances) { - historicActivityInstanceList.add(hai.getActivityId()); - } - - // add current activities to list - List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - historicActivityInstanceList.addAll(highLightedActivities); - - // activities and their sequence-flows - for (ActivityImpl activity : processDefinition.getActivities()) { - int index = historicActivityInstanceList.indexOf(activity.getId()); - - if (index >= 0 && index + 1 < historicActivityInstanceList.size()) { - List pvmTransitionList = activity - .getOutgoingTransitions(); - for (PvmTransition pvmTransition : pvmTransitionList) { - String destinationFlowId = pvmTransition.getDestination().getId(); - if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) { - highLightedFlows.add(pvmTransition.getId()); - } - } - } - } - return highLightedFlows; - } - - private void getActivity(String processInstanceId, ActivityImpl activity, ArrayNode activityArray, - ArrayNode sequenceFlowArray, ProcessInstance processInstance, List highLightedFlows, - Map subProcessInstanceMap) { - - ObjectNode activityJSON = new ObjectMapper().createObjectNode(); - - // Gather info on the multi instance marker - String multiInstance = (String) activity.getProperty("multiInstance"); - if (multiInstance != null) { - if (!"sequential".equals(multiInstance)) { - multiInstance = "parallel"; - } - } - - ActivityBehavior activityBehavior = activity.getActivityBehavior(); - // Gather info on the collapsed marker - Boolean collapsed = (activityBehavior instanceof CallActivityBehavior); - Boolean expanded = (Boolean) activity.getProperty(BpmnParse.PROPERTYNAME_ISEXPANDED); - if (expanded != null) { - collapsed = !expanded; - } - - Boolean isInterrupting = null; - if (activityBehavior instanceof BoundaryEventActivityBehavior) { - isInterrupting = ((BoundaryEventActivityBehavior) activityBehavior).isInterrupting(); - } - - // Outgoing transitions of activity - for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) { - String flowName = (String) sequenceFlow.getProperty("name"); - boolean isHighLighted = (highLightedFlows.contains(sequenceFlow.getId())); - boolean isConditional = sequenceFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION) != null && - !((String) activity.getProperty("type")).toLowerCase().contains("gateway"); - boolean isDefault = sequenceFlow.getId().equals(activity.getProperty("default")) - && ((String) activity.getProperty("type")).toLowerCase().contains("gateway"); - - List waypoints = ((TransitionImpl) sequenceFlow).getWaypoints(); - ArrayNode xPointArray = new ObjectMapper().createArrayNode(); - ArrayNode yPointArray = new ObjectMapper().createArrayNode(); - for (int i = 0; i < waypoints.size(); i += 2) { // waypoints.size() - // minimally 4: x1, y1, - // x2, y2 - xPointArray.add(waypoints.get(i)); - yPointArray.add(waypoints.get(i + 1)); - } - - ObjectNode flowJSON = new ObjectMapper().createObjectNode(); - flowJSON.put("id", sequenceFlow.getId()); - flowJSON.put("name", flowName); - flowJSON.put("flow", "(" + sequenceFlow.getSource().getId() + ")--" - + sequenceFlow.getId() + "-->(" - + sequenceFlow.getDestination().getId() + ")"); - - if (isConditional) - flowJSON.put("isConditional", isConditional); - if (isDefault) - flowJSON.put("isDefault", isDefault); - if (isHighLighted) - flowJSON.put("isHighLighted", isHighLighted); - - flowJSON.put("xPointArray", xPointArray); - flowJSON.put("yPointArray", yPointArray); - - sequenceFlowArray.add(flowJSON); - } - - // Nested activities (boundary events) - ArrayNode nestedActivityArray = new ObjectMapper().createArrayNode(); - for (ActivityImpl nestedActivity : activity.getActivities()) { - nestedActivityArray.add(nestedActivity.getId()); - } - - Map properties = activity.getProperties(); - ObjectNode propertiesJSON = new ObjectMapper().createObjectNode(); - for (String key : properties.keySet()) { - Object prop = properties.get(key); - if (prop instanceof String) - propertiesJSON.put(key, (String) properties.get(key)); - else if (prop instanceof Integer) - propertiesJSON.put(key, (Integer) properties.get(key)); - else if (prop instanceof Boolean) - propertiesJSON.put(key, (Boolean) properties.get(key)); - else if ("initial".equals(key)) { - ActivityImpl act = (ActivityImpl) properties.get(key); - propertiesJSON.put(key, act.getId()); - } else if ("timerDeclarations".equals(key)) { - ArrayList timerDeclarations = (ArrayList) properties.get(key); - ArrayNode timerDeclarationArray = new ObjectMapper().createArrayNode(); - - if (timerDeclarations != null) - for (TimerDeclarationImpl timerDeclaration : timerDeclarations) { - ObjectNode timerDeclarationJSON = new ObjectMapper().createObjectNode(); - - timerDeclarationJSON.put("isExclusive", timerDeclaration.isExclusive()); - if (timerDeclaration.getRepeat() != null) - timerDeclarationJSON.put("repeat", timerDeclaration.getRepeat()); - - timerDeclarationJSON.put("retries", String.valueOf(timerDeclaration.getRetries())); - timerDeclarationJSON.put("type", timerDeclaration.getJobHandlerType()); - timerDeclarationJSON.put("configuration", timerDeclaration.getJobHandlerConfiguration()); - //timerDeclarationJSON.put("expression", timerDeclaration.getDescription()); - - timerDeclarationArray.add(timerDeclarationJSON); - } - if (timerDeclarationArray.size() > 0) - propertiesJSON.put(key, timerDeclarationArray); - // TODO: implement getting description - } else if ("eventDefinitions".equals(key)) { - ArrayList eventDefinitions = (ArrayList) properties.get(key); - ArrayNode eventDefinitionsArray = new ObjectMapper().createArrayNode(); - - if (eventDefinitions != null) { - for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) { - ObjectNode eventDefinitionJSON = new ObjectMapper().createObjectNode(); - - if (eventDefinition.getActivityId() != null) - eventDefinitionJSON.put("activityId",eventDefinition.getActivityId()); - - eventDefinitionJSON.put("eventName", eventDefinition.getEventName()); - eventDefinitionJSON.put("eventType", eventDefinition.getEventType()); - eventDefinitionJSON.put("isAsync", eventDefinition.isAsync()); - eventDefinitionJSON.put("isStartEvent", eventDefinition.isStartEvent()); - eventDefinitionsArray.add(eventDefinitionJSON); - } - } - - if (eventDefinitionsArray.size() > 0) - propertiesJSON.put(key, eventDefinitionsArray); - - // TODO: implement it - } else if ("errorEventDefinitions".equals(key)) { - ArrayList errorEventDefinitions = (ArrayList) properties.get(key); - ArrayNode errorEventDefinitionsArray = new ObjectMapper().createArrayNode(); - - if (errorEventDefinitions != null) { - for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) { - ObjectNode errorEventDefinitionJSON = new ObjectMapper().createObjectNode(); - - if (errorEventDefinition.getErrorCode() != null) - errorEventDefinitionJSON.put("errorCode", errorEventDefinition.getErrorCode()); - else - errorEventDefinitionJSON.putNull("errorCode"); - - errorEventDefinitionJSON.put("handlerActivityId", - errorEventDefinition.getHandlerActivityId()); - - errorEventDefinitionsArray.add(errorEventDefinitionJSON); - } - } - - if (errorEventDefinitionsArray.size() > 0) - propertiesJSON.put(key, errorEventDefinitionsArray); - } - - } - - if ("callActivity".equals(properties.get("type"))) { - CallActivityBehavior callActivityBehavior = null; - - if (activityBehavior instanceof CallActivityBehavior) { - callActivityBehavior = (CallActivityBehavior) activityBehavior; - } - - if (callActivityBehavior != null) { - propertiesJSON.put("processDefinitonKey", callActivityBehavior.getProcessDefinitonKey()); - - // get processDefinitonId from execution or get last processDefinitonId - // by key - ArrayNode processInstanceArray = new ObjectMapper().createArrayNode(); - if (processInstance != null) { - List executionList = runtimeService.createExecutionQuery() - .processInstanceId(processInstanceId) - .activityId(activity.getId()).list(); - if (!executionList.isEmpty()) { - for (Execution execution : executionList) { - ObjectNode processInstanceJSON = subProcessInstanceMap.get(execution.getId()); - processInstanceArray.add(processInstanceJSON); - } - } - } - - // If active activities nas no instance of this callActivity then add - // last definition - if (processInstanceArray.size() == 0 && StringUtils.isNotEmpty(callActivityBehavior.getProcessDefinitonKey())) { - // Get last definition by key - ProcessDefinition lastProcessDefinition = repositoryService - .createProcessDefinitionQuery() - .processDefinitionKey(callActivityBehavior.getProcessDefinitonKey()) - .latestVersion().singleResult(); - - // TODO: unuseful fields there are processDefinitionName, processDefinitionKey - if (lastProcessDefinition != null) { - ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode(); - processInstanceJSON.put("processDefinitionId", lastProcessDefinition.getId()); - processInstanceJSON.put("processDefinitionKey", lastProcessDefinition.getKey()); - processInstanceJSON.put("processDefinitionName", lastProcessDefinition.getName()); - processInstanceArray.add(processInstanceJSON); - } - } - - if (processInstanceArray.size() > 0) { - propertiesJSON.put("processDefinitons", processInstanceArray); - } - } - } - - activityJSON.put("activityId", activity.getId()); - activityJSON.put("properties", propertiesJSON); - if (multiInstance != null) - activityJSON.put("multiInstance", multiInstance); - if (collapsed) - activityJSON.put("collapsed", collapsed); - if (nestedActivityArray.size() > 0) - activityJSON.put("nestedActivities", nestedActivityArray); - if (isInterrupting != null) - activityJSON.put("isInterrupting", isInterrupting); - - activityJSON.put("x", activity.getX()); - activityJSON.put("y", activity.getY()); - activityJSON.put("width", activity.getWidth()); - activityJSON.put("height", activity.getHeight()); - - activityArray.add(activityJSON); - - // Nested activities (boundary events) - for (ActivityImpl nestedActivity : activity.getActivities()) { - getActivity(processInstanceId, nestedActivity, activityArray, sequenceFlowArray, - processInstance, highLightedFlows, subProcessInstanceMap); - } - } - - private JsonNode getProcessDefinitionResponse(ProcessDefinitionEntity processDefinition) { - ObjectMapper mapper = new ObjectMapper(); - ObjectNode pdrJSON = mapper.createObjectNode(); - pdrJSON.put("id", processDefinition.getId()); - pdrJSON.put("name", processDefinition.getName()); - pdrJSON.put("key", processDefinition.getKey()); - pdrJSON.put("version", processDefinition.getVersion()); - pdrJSON.put("deploymentId", processDefinition.getDeploymentId()); - pdrJSON.put("isGraphicNotationDefined", isGraphicNotationDefined(processDefinition)); - return pdrJSON; - } - - private boolean isGraphicNotationDefined(ProcessDefinitionEntity processDefinition) { - return ((ProcessDefinitionEntity) repositoryService - .getProcessDefinition(processDefinition.getId())) - .isGraphicalNotationDefined(); - } -} +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.activiti.rest.diagram.services; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.activiti.engine.ActivitiException; +import org.activiti.engine.ActivitiObjectNotFoundException; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior; +import org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior; +import org.activiti.engine.impl.bpmn.parser.BpmnParse; +import org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition; +import org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration; +import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl; +import org.activiti.engine.impl.persistence.entity.ExecutionEntity; +import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.activiti.engine.impl.pvm.PvmTransition; +import org.activiti.engine.impl.pvm.delegate.ActivityBehavior; +import org.activiti.engine.impl.pvm.process.ActivityImpl; +import org.activiti.engine.impl.pvm.process.Lane; +import org.activiti.engine.impl.pvm.process.LaneSet; +import org.activiti.engine.impl.pvm.process.ParticipantProcess; +import org.activiti.engine.impl.pvm.process.TransitionImpl; +import org.activiti.engine.repository.ProcessDefinition; +import org.activiti.engine.runtime.Execution; +import org.activiti.engine.runtime.ProcessInstance; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; + +public class BaseProcessDefinitionDiagramLayoutResource { + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private RepositoryService repositoryService; + + @Autowired + private HistoryService historyService; + + public ObjectNode getDiagramNode(String processInstanceId, String processDefinitionId) { + + List highLightedFlows = Collections. emptyList(); + List highLightedActivities = Collections. emptyList(); + + Map subProcessInstanceMap = new HashMap(); + + ProcessInstance processInstance = null; + if (processInstanceId != null) { + processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + if (processInstance == null) { + throw new ActivitiObjectNotFoundException("Process instance could not be found"); + } + processDefinitionId = processInstance.getProcessDefinitionId(); + + List subProcessInstances = runtimeService + .createProcessInstanceQuery() + .superProcessInstanceId(processInstanceId).list(); + + for (ProcessInstance subProcessInstance : subProcessInstances) { + String subDefId = subProcessInstance.getProcessDefinitionId(); + + String superExecutionId = ((ExecutionEntity) subProcessInstance) + .getSuperExecutionId(); + ProcessDefinitionEntity subDef = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(subDefId); + + ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode(); + processInstanceJSON.put("processInstanceId", subProcessInstance.getId()); + processInstanceJSON.put("superExecutionId", superExecutionId); + processInstanceJSON.put("processDefinitionId", subDef.getId()); + processInstanceJSON.put("processDefinitionKey", subDef.getKey()); + processInstanceJSON.put("processDefinitionName", subDef.getName()); + + subProcessInstanceMap.put(superExecutionId, processInstanceJSON); + } + } + + if (processDefinitionId == null) { + throw new ActivitiObjectNotFoundException("No process definition id provided"); + } + + ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processDefinitionId); + + if (processDefinition == null) { + throw new ActivitiException("Process definition " + processDefinitionId + " could not be found"); + } + + ObjectNode responseJSON = new ObjectMapper().createObjectNode(); + + // Process definition + JsonNode pdrJSON = getProcessDefinitionResponse(processDefinition); + + if (pdrJSON != null) { + responseJSON.set("processDefinition", pdrJSON); + } + + // Highlighted activities + if (processInstance != null) { + ArrayNode activityArray = new ObjectMapper().createArrayNode(); + ArrayNode flowsArray = new ObjectMapper().createArrayNode(); + + highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); + highLightedFlows = getHighLightedFlows(processInstanceId, processDefinition); + + for (String activityName : highLightedActivities) { + activityArray.add(activityName); + } + + for (String flow : highLightedFlows) + flowsArray.add(flow); + + responseJSON.set("highLightedActivities", activityArray); + responseJSON.set("highLightedFlows", flowsArray); + } + + // Pool shape, if process is participant in collaboration + if (processDefinition.getParticipantProcess() != null) { + ParticipantProcess pProc = processDefinition.getParticipantProcess(); + + ObjectNode participantProcessJSON = new ObjectMapper().createObjectNode(); + participantProcessJSON.put("id", pProc.getId()); + if (StringUtils.isNotEmpty(pProc.getName())) { + participantProcessJSON.put("name", pProc.getName()); + } else { + participantProcessJSON.put("name", ""); + } + participantProcessJSON.put("x", pProc.getX()); + participantProcessJSON.put("y", pProc.getY()); + participantProcessJSON.put("width", pProc.getWidth()); + participantProcessJSON.put("height", pProc.getHeight()); + + responseJSON.set("participantProcess", participantProcessJSON); + } + + // Draw lanes + + if (processDefinition.getLaneSets() != null && !processDefinition.getLaneSets().isEmpty()) { + ArrayNode laneSetArray = new ObjectMapper().createArrayNode(); + for (LaneSet laneSet : processDefinition.getLaneSets()) { + ArrayNode laneArray = new ObjectMapper().createArrayNode(); + if (laneSet.getLanes() != null && !laneSet.getLanes().isEmpty()) { + for (Lane lane : laneSet.getLanes()) { + ObjectNode laneJSON = new ObjectMapper().createObjectNode(); + laneJSON.put("id", lane.getId()); + if (StringUtils.isNotEmpty(lane.getName())) { + laneJSON.put("name", lane.getName()); + } else { + laneJSON.put("name", ""); + } + laneJSON.put("x", lane.getX()); + laneJSON.put("y", lane.getY()); + laneJSON.put("width", lane.getWidth()); + laneJSON.put("height", lane.getHeight()); + + List flowNodeIds = lane.getFlowNodeIds(); + ArrayNode flowNodeIdsArray = new ObjectMapper().createArrayNode(); + for (String flowNodeId : flowNodeIds) { + flowNodeIdsArray.add(flowNodeId); + } + laneJSON.set("flowNodeIds", flowNodeIdsArray); + + laneArray.add(laneJSON); + } + } + ObjectNode laneSetJSON = new ObjectMapper().createObjectNode(); + laneSetJSON.put("id", laneSet.getId()); + if (StringUtils.isNotEmpty(laneSet.getName())) { + laneSetJSON.put("name", laneSet.getName()); + } else { + laneSetJSON.put("name", ""); + } + laneSetJSON.set("lanes", laneArray); + + laneSetArray.add(laneSetJSON); + } + + if (laneSetArray.size() > 0) + responseJSON.set("laneSets", laneSetArray); + } + + ArrayNode sequenceFlowArray = new ObjectMapper().createArrayNode(); + ArrayNode activityArray = new ObjectMapper().createArrayNode(); + + // Activities and their sequence-flows + + for (ActivityImpl activity : processDefinition.getActivities()) { + getActivity(processInstanceId, activity, activityArray, sequenceFlowArray, + processInstance, highLightedFlows, subProcessInstanceMap); + } + + responseJSON.set("activities", activityArray); + responseJSON.set("sequenceFlows", sequenceFlowArray); + + return responseJSON; + } + + private List getHighLightedFlows(String processInstanceId, ProcessDefinitionEntity processDefinition) { + + List highLightedFlows = new ArrayList(); + List historicActivityInstances = historyService + .createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId) + .orderByHistoricActivityInstanceStartTime().asc().list(); + + List historicActivityInstanceList = new ArrayList(); + for (HistoricActivityInstance hai : historicActivityInstances) { + historicActivityInstanceList.add(hai.getActivityId()); + } + + // add current activities to list + List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); + historicActivityInstanceList.addAll(highLightedActivities); + + // activities and their sequence-flows + for (ActivityImpl activity : processDefinition.getActivities()) { + int index = historicActivityInstanceList.indexOf(activity.getId()); + + if (index >= 0 && index + 1 < historicActivityInstanceList.size()) { + List pvmTransitionList = activity + .getOutgoingTransitions(); + for (PvmTransition pvmTransition : pvmTransitionList) { + String destinationFlowId = pvmTransition.getDestination().getId(); + if (destinationFlowId.equals(historicActivityInstanceList.get(index + 1))) { + highLightedFlows.add(pvmTransition.getId()); + } + } + } + } + return highLightedFlows; + } + + private void getActivity(String processInstanceId, ActivityImpl activity, ArrayNode activityArray, + ArrayNode sequenceFlowArray, ProcessInstance processInstance, List highLightedFlows, + Map subProcessInstanceMap) { + + ObjectNode activityJSON = new ObjectMapper().createObjectNode(); + + // Gather info on the multi instance marker + String multiInstance = (String) activity.getProperty("multiInstance"); + if (multiInstance != null) { + if (!"sequential".equals(multiInstance)) { + multiInstance = "parallel"; + } + } + + ActivityBehavior activityBehavior = activity.getActivityBehavior(); + // Gather info on the collapsed marker + Boolean collapsed = (activityBehavior instanceof CallActivityBehavior); + Boolean expanded = (Boolean) activity.getProperty(BpmnParse.PROPERTYNAME_ISEXPANDED); + if (expanded != null) { + collapsed = !expanded; + } + + Boolean isInterrupting = null; + if (activityBehavior instanceof BoundaryEventActivityBehavior) { + isInterrupting = ((BoundaryEventActivityBehavior) activityBehavior).isInterrupting(); + } + + // Outgoing transitions of activity + for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) { + String flowName = (String) sequenceFlow.getProperty("name"); + boolean isHighLighted = (highLightedFlows.contains(sequenceFlow.getId())); + boolean isConditional = sequenceFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION) != null && + !((String) activity.getProperty("type")).toLowerCase().contains("gateway"); + boolean isDefault = sequenceFlow.getId().equals(activity.getProperty("default")) + && ((String) activity.getProperty("type")).toLowerCase().contains("gateway"); + + List waypoints = ((TransitionImpl) sequenceFlow).getWaypoints(); + ArrayNode xPointArray = new ObjectMapper().createArrayNode(); + ArrayNode yPointArray = new ObjectMapper().createArrayNode(); + for (int i = 0; i < waypoints.size(); i += 2) { // waypoints.size() + // minimally 4: x1, y1, + // x2, y2 + xPointArray.add(waypoints.get(i)); + yPointArray.add(waypoints.get(i + 1)); + } + + ObjectNode flowJSON = new ObjectMapper().createObjectNode(); + flowJSON.put("id", sequenceFlow.getId()); + flowJSON.put("name", flowName); + flowJSON.put("flow", "(" + sequenceFlow.getSource().getId() + ")--" + + sequenceFlow.getId() + "-->(" + + sequenceFlow.getDestination().getId() + ")"); + + if (isConditional) + flowJSON.put("isConditional", isConditional); + if (isDefault) + flowJSON.put("isDefault", isDefault); + if (isHighLighted) + flowJSON.put("isHighLighted", isHighLighted); + + flowJSON.set("xPointArray", xPointArray); + flowJSON.set("yPointArray", yPointArray); + + sequenceFlowArray.add(flowJSON); + } + + // Nested activities (boundary events) + ArrayNode nestedActivityArray = new ObjectMapper().createArrayNode(); + for (ActivityImpl nestedActivity : activity.getActivities()) { + nestedActivityArray.add(nestedActivity.getId()); + } + + Map properties = activity.getProperties(); + ObjectNode propertiesJSON = new ObjectMapper().createObjectNode(); + for (String key : properties.keySet()) { + Object prop = properties.get(key); + if (prop instanceof String) + propertiesJSON.put(key, (String) properties.get(key)); + else if (prop instanceof Integer) + propertiesJSON.put(key, (Integer) properties.get(key)); + else if (prop instanceof Boolean) + propertiesJSON.put(key, (Boolean) properties.get(key)); + else if ("initial".equals(key)) { + ActivityImpl act = (ActivityImpl) properties.get(key); + propertiesJSON.put(key, act.getId()); + } else if ("timerDeclarations".equals(key)) { + ArrayList timerDeclarations = (ArrayList) properties.get(key); + ArrayNode timerDeclarationArray = new ObjectMapper().createArrayNode(); + + if (timerDeclarations != null) + for (TimerDeclarationImpl timerDeclaration : timerDeclarations) { + ObjectNode timerDeclarationJSON = new ObjectMapper().createObjectNode(); + + timerDeclarationJSON.put("isExclusive", timerDeclaration.isExclusive()); + if (timerDeclaration.getRepeat() != null) + timerDeclarationJSON.put("repeat", timerDeclaration.getRepeat()); + + timerDeclarationJSON.put("retries", String.valueOf(timerDeclaration.getRetries())); + timerDeclarationJSON.put("type", timerDeclaration.getJobHandlerType()); + timerDeclarationJSON.put("configuration", timerDeclaration.getJobHandlerConfiguration()); + //timerDeclarationJSON.put("expression", timerDeclaration.getDescription()); + + timerDeclarationArray.add(timerDeclarationJSON); + } + if (timerDeclarationArray.size() > 0) + propertiesJSON.set(key, timerDeclarationArray); + // TODO: implement getting description + } else if ("eventDefinitions".equals(key)) { + ArrayList eventDefinitions = (ArrayList) properties.get(key); + ArrayNode eventDefinitionsArray = new ObjectMapper().createArrayNode(); + + if (eventDefinitions != null) { + for (EventSubscriptionDeclaration eventDefinition : eventDefinitions) { + ObjectNode eventDefinitionJSON = new ObjectMapper().createObjectNode(); + + if (eventDefinition.getActivityId() != null) + eventDefinitionJSON.put("activityId",eventDefinition.getActivityId()); + + eventDefinitionJSON.put("eventName", eventDefinition.getEventName()); + eventDefinitionJSON.put("eventType", eventDefinition.getEventType()); + eventDefinitionJSON.put("isAsync", eventDefinition.isAsync()); + eventDefinitionJSON.put("isStartEvent", eventDefinition.isStartEvent()); + eventDefinitionsArray.add(eventDefinitionJSON); + } + } + + if (eventDefinitionsArray.size() > 0) + propertiesJSON.set(key, eventDefinitionsArray); + + // TODO: implement it + } else if ("errorEventDefinitions".equals(key)) { + ArrayList errorEventDefinitions = (ArrayList) properties.get(key); + ArrayNode errorEventDefinitionsArray = new ObjectMapper().createArrayNode(); + + if (errorEventDefinitions != null) { + for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) { + ObjectNode errorEventDefinitionJSON = new ObjectMapper().createObjectNode(); + + if (errorEventDefinition.getErrorCode() != null) + errorEventDefinitionJSON.put("errorCode", errorEventDefinition.getErrorCode()); + else + errorEventDefinitionJSON.putNull("errorCode"); + + errorEventDefinitionJSON.put("handlerActivityId", + errorEventDefinition.getHandlerActivityId()); + + errorEventDefinitionsArray.add(errorEventDefinitionJSON); + } + } + + if (errorEventDefinitionsArray.size() > 0) + propertiesJSON.set(key, errorEventDefinitionsArray); + } + + } + + if ("callActivity".equals(properties.get("type"))) { + CallActivityBehavior callActivityBehavior = null; + + if (activityBehavior instanceof CallActivityBehavior) { + callActivityBehavior = (CallActivityBehavior) activityBehavior; + } + + if (callActivityBehavior != null) { + propertiesJSON.put("processDefinitonKey", callActivityBehavior.getProcessDefinitonKey()); + + // get processDefinitonId from execution or get last processDefinitonId + // by key + ArrayNode processInstanceArray = new ObjectMapper().createArrayNode(); + if (processInstance != null) { + List executionList = runtimeService.createExecutionQuery() + .processInstanceId(processInstanceId) + .activityId(activity.getId()).list(); + if (!executionList.isEmpty()) { + for (Execution execution : executionList) { + ObjectNode processInstanceJSON = subProcessInstanceMap.get(execution.getId()); + processInstanceArray.add(processInstanceJSON); + } + } + } + + // If active activities nas no instance of this callActivity then add + // last definition + if (processInstanceArray.size() == 0 && StringUtils.isNotEmpty(callActivityBehavior.getProcessDefinitonKey())) { + // Get last definition by key + ProcessDefinition lastProcessDefinition = repositoryService + .createProcessDefinitionQuery() + .processDefinitionKey(callActivityBehavior.getProcessDefinitonKey()) + .latestVersion().singleResult(); + + // TODO: unuseful fields there are processDefinitionName, processDefinitionKey + if (lastProcessDefinition != null) { + ObjectNode processInstanceJSON = new ObjectMapper().createObjectNode(); + processInstanceJSON.put("processDefinitionId", lastProcessDefinition.getId()); + processInstanceJSON.put("processDefinitionKey", lastProcessDefinition.getKey()); + processInstanceJSON.put("processDefinitionName", lastProcessDefinition.getName()); + processInstanceArray.add(processInstanceJSON); + } + } + + if (processInstanceArray.size() > 0) { + propertiesJSON.set("processDefinitons", processInstanceArray); + } + } + } + + activityJSON.put("activityId", activity.getId()); + activityJSON.set("properties", propertiesJSON); + if (multiInstance != null) + activityJSON.put("multiInstance", multiInstance); + if (collapsed) + activityJSON.put("collapsed", collapsed); + if (nestedActivityArray.size() > 0) + activityJSON.set("nestedActivities", nestedActivityArray); + if (isInterrupting != null) + activityJSON.put("isInterrupting", isInterrupting); + + activityJSON.put("x", activity.getX()); + activityJSON.put("y", activity.getY()); + activityJSON.put("width", activity.getWidth()); + activityJSON.put("height", activity.getHeight()); + + activityArray.add(activityJSON); + + // Nested activities (boundary events) + for (ActivityImpl nestedActivity : activity.getActivities()) { + getActivity(processInstanceId, nestedActivity, activityArray, sequenceFlowArray, + processInstance, highLightedFlows, subProcessInstanceMap); + } + } + + private JsonNode getProcessDefinitionResponse(ProcessDefinitionEntity processDefinition) { + ObjectMapper mapper = new ObjectMapper(); + ObjectNode pdrJSON = mapper.createObjectNode(); + pdrJSON.put("id", processDefinition.getId()); + pdrJSON.put("name", processDefinition.getName()); + pdrJSON.put("key", processDefinition.getKey()); + pdrJSON.put("version", processDefinition.getVersion()); + pdrJSON.put("deploymentId", processDefinition.getDeploymentId()); + pdrJSON.put("isGraphicNotationDefined", isGraphicNotationDefined(processDefinition)); + return pdrJSON; + } + + private boolean isGraphicNotationDefined(ProcessDefinitionEntity processDefinition) { + return ((ProcessDefinitionEntity) repositoryService + .getProcessDefinition(processDefinition.getId())) + .isGraphicalNotationDefined(); + } +} diff --git a/len-activiti/src/main/java/org/activiti/rest/diagram/services/ProcessInstanceHighlightsResource.java b/len-activiti/src/main/java/org/activiti/rest/diagram/services/ProcessInstanceHighlightsResource.java index 78983ce..387991d 100644 --- a/len-activiti/src/main/java/org/activiti/rest/diagram/services/ProcessInstanceHighlightsResource.java +++ b/len-activiti/src/main/java/org/activiti/rest/diagram/services/ProcessInstanceHighlightsResource.java @@ -1,255 +1,255 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.activiti.rest.diagram.services; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import org.activiti.engine.HistoryService; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.RuntimeService; -import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; -import org.activiti.engine.impl.pvm.PvmTransition; -import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.runtime.ProcessInstance; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class ProcessInstanceHighlightsResource { - - @Autowired - private RuntimeService runtimeService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private HistoryService historyService; - - protected ObjectMapper objectMapper = new ObjectMapper(); - - @RequestMapping(value="/process-instance/{processInstanceId}/highlights", method = RequestMethod.GET, produces = "application/json") - public ObjectNode getHighlighted(@PathVariable String processInstanceId) { - - ObjectNode responseJSON = objectMapper.createObjectNode(); - - responseJSON.put("processInstanceId", processInstanceId); - - ArrayNode activitiesArray = objectMapper.createArrayNode(); - ArrayNode flowsArray = objectMapper.createArrayNode(); - - try { - ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); - - responseJSON.put("processDefinitionId", processInstance.getProcessDefinitionId()); - - List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - List highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId); - - for (String activityId : highLightedActivities) { - activitiesArray.add(activityId); - } - - for (String flow : highLightedFlows) { - flowsArray.add(flow); - } - - } catch (Exception e) { - e.printStackTrace(); - } - - responseJSON.put("activities", activitiesArray); - responseJSON.put("flows", flowsArray); - - return responseJSON; - } - - - /** - * getHighLightedFlows - * - * @param processDefinition - * @param processInstanceId - * @return - */ - private List getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) { - - List highLightedFlows = new ArrayList(); - - List historicActivityInstances = historyService.createHistoricActivityInstanceQuery() - .processInstanceId(processInstanceId) - //order by startime asc is not correct. use default order is correct. - //.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/ - .list(); - - LinkedList hisActInstList = new LinkedList(); - hisActInstList.addAll(historicActivityInstances); - - getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows); - - return highLightedFlows; - } - - /** - * getHighlightedFlows - * - * code logic: - * 1. Loop all activities by id asc order; - * 2. Check each activity's outgoing transitions and eventBoundery outgoing transitions, if outgoing transitions's destination.id is in other executed activityIds, add this transition to highLightedFlows List; - * 3. But if activity is not a parallelGateway or inclusiveGateway, only choose the earliest flow. - * - * @param activityList - * @param hisActInstList - * @param highLightedFlows - */ - private void getHighlightedFlows(List activityList, LinkedList hisActInstList, List highLightedFlows){ - - //check out startEvents in activityList - List startEventActList = new ArrayList(); - Map activityMap = new HashMap(activityList.size()); - for(ActivityImpl activity : activityList){ - - activityMap.put(activity.getId(), activity); - - String actType = (String) activity.getProperty("type"); - if (actType != null && actType.toLowerCase().indexOf("startevent") >= 0){ - startEventActList.add(activity); - } - } - - //These codes is used to avoid a bug: - //ACT-1728 If the process instance was started by a callActivity, it will be not have the startEvent activity in ACT_HI_ACTINST table - //Code logic: - //Check the first activity if it is a startEvent, if not check out the startEvent's highlight outgoing flow. - HistoricActivityInstance firstHistActInst = hisActInstList.getFirst(); - String firstActType = (String) firstHistActInst.getActivityType(); - if (firstActType != null && firstActType.toLowerCase().indexOf("startevent") < 0){ - PvmTransition startTrans = getStartTransaction(startEventActList, firstHistActInst); - if (startTrans != null){ - highLightedFlows.add(startTrans.getId()); - } - } - - while (!hisActInstList.isEmpty()) { - HistoricActivityInstance histActInst = hisActInstList.removeFirst(); - ActivityImpl activity = activityMap.get(histActInst.getActivityId()); - if (activity != null) { - boolean isParallel = false; - String type = histActInst.getActivityType(); - if ("parallelGateway".equals(type) || "inclusiveGateway".equals(type)){ - isParallel = true; - } else if ("subProcess".equals(histActInst.getActivityType())){ - getHighlightedFlows(activity.getActivities(), hisActInstList, highLightedFlows); - } - - List allOutgoingTrans = new ArrayList(); - allOutgoingTrans.addAll(activity.getOutgoingTransitions()); - allOutgoingTrans.addAll(getBoundaryEventOutgoingTransitions(activity)); - List activityHighLightedFlowIds = getHighlightedFlows(allOutgoingTrans, hisActInstList, isParallel); - highLightedFlows.addAll(activityHighLightedFlowIds); - } - } - } - - /** - * Check out the outgoing transition connected to firstActInst from startEventActList - * - * @param startEventActList - * @param firstActInst - * @return - */ - private PvmTransition getStartTransaction(List startEventActList, HistoricActivityInstance firstActInst){ - for (ActivityImpl startEventAct: startEventActList) { - for (PvmTransition trans : startEventAct.getOutgoingTransitions()) { - if (trans.getDestination().getId().equals(firstActInst.getActivityId())) { - return trans; - } - } - } - return null; - } - - /** - * getBoundaryEventOutgoingTransitions - * - * @param activity - * @return - */ - private List getBoundaryEventOutgoingTransitions(ActivityImpl activity){ - List boundaryTrans = new ArrayList(); - for(ActivityImpl subActivity : activity.getActivities()){ - String type = (String)subActivity.getProperty("type"); - if(type!=null && type.toLowerCase().indexOf("boundary")>=0){ - boundaryTrans.addAll(subActivity.getOutgoingTransitions()); - } - } - return boundaryTrans; - } - - /** - * find out single activity's highlighted flowIds - * - * @param activity - * @param hisActInstList - * @param isExclusive if true only return one flowId(Such as exclusiveGateway, BoundaryEvent On Task) - * @return - */ - private List getHighlightedFlows(List pvmTransitionList, LinkedList hisActInstList, boolean isParallel){ - - List highLightedFlowIds = new ArrayList(); - - PvmTransition earliestTrans = null; - HistoricActivityInstance earliestHisActInst = null; - - for (PvmTransition pvmTransition : pvmTransitionList) { - - String destActId = pvmTransition.getDestination().getId(); - HistoricActivityInstance destHisActInst = findHisActInst(hisActInstList, destActId); - if (destHisActInst != null) { - if (isParallel) { - highLightedFlowIds.add(pvmTransition.getId()); - } else if (earliestHisActInst == null || (earliestHisActInst.getId().compareTo(destHisActInst.getId()) > 0)) { - earliestTrans = pvmTransition; - earliestHisActInst = destHisActInst; - } - } - } - - if ((!isParallel) && earliestTrans!=null){ - highLightedFlowIds.add(earliestTrans.getId()); - } - - return highLightedFlowIds; - } - - private HistoricActivityInstance findHisActInst(LinkedList hisActInstList, String actId){ - for (HistoricActivityInstance hisActInst : hisActInstList){ - if (hisActInst.getActivityId().equals(actId)){ - return hisActInst; - } - } - return null; - } -} +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.activiti.rest.diagram.services; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.activiti.engine.HistoryService; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.RuntimeService; +import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.activiti.engine.impl.pvm.PvmTransition; +import org.activiti.engine.impl.pvm.process.ActivityImpl; +import org.activiti.engine.runtime.ProcessInstance; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ProcessInstanceHighlightsResource { + + @Autowired + private RuntimeService runtimeService; + + @Autowired + private RepositoryService repositoryService; + + @Autowired + private HistoryService historyService; + + protected ObjectMapper objectMapper = new ObjectMapper(); + + @RequestMapping(value="/process-instance/{processInstanceId}/highlights", method = RequestMethod.GET, produces = "application/json") + public ObjectNode getHighlighted(@PathVariable String processInstanceId) { + + ObjectNode responseJSON = objectMapper.createObjectNode(); + + responseJSON.put("processInstanceId", processInstanceId); + + ArrayNode activitiesArray = objectMapper.createArrayNode(); + ArrayNode flowsArray = objectMapper.createArrayNode(); + + try { + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); + ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance.getProcessDefinitionId()); + + responseJSON.put("processDefinitionId", processInstance.getProcessDefinitionId()); + + List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); + List highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId); + + for (String activityId : highLightedActivities) { + activitiesArray.add(activityId); + } + + for (String flow : highLightedFlows) { + flowsArray.add(flow); + } + + } catch (Exception e) { + e.printStackTrace(); + } + + responseJSON.set("activities", activitiesArray); + responseJSON.set("flows", flowsArray); + + return responseJSON; + } + + + /** + * getHighLightedFlows + * + * @param processDefinition + * @param processInstanceId + * @return + */ + private List getHighLightedFlows(ProcessDefinitionEntity processDefinition, String processInstanceId) { + + List highLightedFlows = new ArrayList(); + + List historicActivityInstances = historyService.createHistoricActivityInstanceQuery() + .processInstanceId(processInstanceId) + //order by startime asc is not correct. use default order is correct. + //.orderByHistoricActivityInstanceStartTime().asc()/*.orderByActivityId().asc()*/ + .list(); + + LinkedList hisActInstList = new LinkedList(); + hisActInstList.addAll(historicActivityInstances); + + getHighlightedFlows(processDefinition.getActivities(), hisActInstList, highLightedFlows); + + return highLightedFlows; + } + + /** + * getHighlightedFlows + * + * code logic: + * 1. Loop all activities by id asc order; + * 2. Check each activity's outgoing transitions and eventBoundery outgoing transitions, if outgoing transitions's destination.id is in other executed activityIds, add this transition to highLightedFlows List; + * 3. But if activity is not a parallelGateway or inclusiveGateway, only choose the earliest flow. + * + * @param activityList + * @param hisActInstList + * @param highLightedFlows + */ + private void getHighlightedFlows(List activityList, LinkedList hisActInstList, List highLightedFlows){ + + //check out startEvents in activityList + List startEventActList = new ArrayList(); + Map activityMap = new HashMap(activityList.size()); + for(ActivityImpl activity : activityList){ + + activityMap.put(activity.getId(), activity); + + String actType = (String) activity.getProperty("type"); + if (actType != null && actType.toLowerCase().indexOf("startevent") >= 0){ + startEventActList.add(activity); + } + } + + //These codes is used to avoid a bug: + //ACT-1728 If the process instance was started by a callActivity, it will be not have the startEvent activity in ACT_HI_ACTINST table + //Code logic: + //Check the first activity if it is a startEvent, if not check out the startEvent's highlight outgoing flow. + HistoricActivityInstance firstHistActInst = hisActInstList.getFirst(); + String firstActType = (String) firstHistActInst.getActivityType(); + if (firstActType != null && firstActType.toLowerCase().indexOf("startevent") < 0){ + PvmTransition startTrans = getStartTransaction(startEventActList, firstHistActInst); + if (startTrans != null){ + highLightedFlows.add(startTrans.getId()); + } + } + + while (!hisActInstList.isEmpty()) { + HistoricActivityInstance histActInst = hisActInstList.removeFirst(); + ActivityImpl activity = activityMap.get(histActInst.getActivityId()); + if (activity != null) { + boolean isParallel = false; + String type = histActInst.getActivityType(); + if ("parallelGateway".equals(type) || "inclusiveGateway".equals(type)){ + isParallel = true; + } else if ("subProcess".equals(histActInst.getActivityType())){ + getHighlightedFlows(activity.getActivities(), hisActInstList, highLightedFlows); + } + + List allOutgoingTrans = new ArrayList(); + allOutgoingTrans.addAll(activity.getOutgoingTransitions()); + allOutgoingTrans.addAll(getBoundaryEventOutgoingTransitions(activity)); + List activityHighLightedFlowIds = getHighlightedFlows(allOutgoingTrans, hisActInstList, isParallel); + highLightedFlows.addAll(activityHighLightedFlowIds); + } + } + } + + /** + * Check out the outgoing transition connected to firstActInst from startEventActList + * + * @param startEventActList + * @param firstActInst + * @return + */ + private PvmTransition getStartTransaction(List startEventActList, HistoricActivityInstance firstActInst){ + for (ActivityImpl startEventAct: startEventActList) { + for (PvmTransition trans : startEventAct.getOutgoingTransitions()) { + if (trans.getDestination().getId().equals(firstActInst.getActivityId())) { + return trans; + } + } + } + return null; + } + + /** + * getBoundaryEventOutgoingTransitions + * + * @param activity + * @return + */ + private List getBoundaryEventOutgoingTransitions(ActivityImpl activity){ + List boundaryTrans = new ArrayList(); + for(ActivityImpl subActivity : activity.getActivities()){ + String type = (String)subActivity.getProperty("type"); + if(type!=null && type.toLowerCase().indexOf("boundary")>=0){ + boundaryTrans.addAll(subActivity.getOutgoingTransitions()); + } + } + return boundaryTrans; + } + + /** + * find out single activity's highlighted flowIds + * + * @param activity + * @param hisActInstList + * @param isExclusive if true only return one flowId(Such as exclusiveGateway, BoundaryEvent On Task) + * @return + */ + private List getHighlightedFlows(List pvmTransitionList, LinkedList hisActInstList, boolean isParallel){ + + List highLightedFlowIds = new ArrayList(); + + PvmTransition earliestTrans = null; + HistoricActivityInstance earliestHisActInst = null; + + for (PvmTransition pvmTransition : pvmTransitionList) { + + String destActId = pvmTransition.getDestination().getId(); + HistoricActivityInstance destHisActInst = findHisActInst(hisActInstList, destActId); + if (destHisActInst != null) { + if (isParallel) { + highLightedFlowIds.add(pvmTransition.getId()); + } else if (earliestHisActInst == null || (earliestHisActInst.getId().compareTo(destHisActInst.getId()) > 0)) { + earliestTrans = pvmTransition; + earliestHisActInst = destHisActInst; + } + } + } + + if ((!isParallel) && earliestTrans!=null){ + highLightedFlowIds.add(earliestTrans.getId()); + } + + return highLightedFlowIds; + } + + private HistoricActivityInstance findHisActInst(LinkedList hisActInstList, String actId){ + for (HistoricActivityInstance hisActInst : hisActInstList){ + if (hisActInst.getActivityId().equals(actId)){ + return hisActInst; + } + } + return null; + } +} diff --git a/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelEditorJsonRestResource.java b/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelEditorJsonRestResource.java index 3305bbf..e50c6b8 100644 --- a/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelEditorJsonRestResource.java +++ b/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelEditorJsonRestResource.java @@ -1,71 +1,71 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.rest.editor.model; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.activiti.editor.constants.ModelDataJsonConstants; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.repository.Model; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Tijs Rademakers - */ -@RestController -@RequestMapping("service") -public class ModelEditorJsonRestResource implements ModelDataJsonConstants { - - protected static final Logger LOGGER = LoggerFactory.getLogger(ModelEditorJsonRestResource.class); - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private ObjectMapper objectMapper; - - @RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json") - public ObjectNode getEditorJson(@PathVariable String modelId) { - ObjectNode modelNode = null; - - Model model = repositoryService.getModel(modelId); - - if (model != null) { - try { - if (StringUtils.isNotEmpty(model.getMetaInfo())) { - modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); - } else { - modelNode = objectMapper.createObjectNode(); - modelNode.put(MODEL_NAME, model.getName()); - } - modelNode.put(MODEL_ID, model.getId()); - ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree( - new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")); - modelNode.put("model", editorJsonNode); - - } catch (Exception e) { - LOGGER.error("Error creating model JSON", e); - throw new ActivitiException("Error creating model JSON", e); - } - } - return modelNode; - } -} +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.rest.editor.model; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.activiti.editor.constants.ModelDataJsonConstants; +import org.activiti.engine.ActivitiException; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.repository.Model; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Tijs Rademakers + */ +@RestController +@RequestMapping("service") +public class ModelEditorJsonRestResource implements ModelDataJsonConstants { + + protected static final Logger LOGGER = LoggerFactory.getLogger(ModelEditorJsonRestResource.class); + + @Autowired + private RepositoryService repositoryService; + + @Autowired + private ObjectMapper objectMapper; + + @RequestMapping(value="/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json") + public ObjectNode getEditorJson(@PathVariable String modelId) { + ObjectNode modelNode = null; + + Model model = repositoryService.getModel(modelId); + + if (model != null) { + try { + if (StringUtils.isNotEmpty(model.getMetaInfo())) { + modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo()); + } else { + modelNode = objectMapper.createObjectNode(); + modelNode.put(MODEL_NAME, model.getName()); + } + modelNode.put(MODEL_ID, model.getId()); + ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree( + new String(repositoryService.getModelEditorSource(model.getId()), "utf-8")); + modelNode.set("model", editorJsonNode); + + } catch (Exception e) { + LOGGER.error("Error creating model JSON", e); + throw new ActivitiException("Error creating model JSON", e); + } + } + return modelNode; + } +} diff --git a/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelSaveRestResource.java b/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelSaveRestResource.java index e28bf19..76701a6 100644 --- a/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelSaveRestResource.java +++ b/len-activiti/src/main/java/org/activiti/rest/editor/model/ModelSaveRestResource.java @@ -1,104 +1,103 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.activiti.rest.editor.model; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.activiti.editor.constants.ModelDataJsonConstants; -import org.activiti.engine.ActivitiException; -import org.activiti.engine.RepositoryService; -import org.activiti.engine.repository.Model; -import org.apache.batik.transcoder.TranscoderInput; -import org.apache.batik.transcoder.TranscoderOutput; -import org.apache.batik.transcoder.image.PNGTranscoder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Tijs Rademakers - */ -@RestController -@RequestMapping("service") -public class ModelSaveRestResource implements ModelDataJsonConstants { - - protected static final Logger LOGGER = LoggerFactory.getLogger(ModelSaveRestResource.class); - - @Autowired - private RepositoryService repositoryService; - - - @PostMapping(value="/model/{modelId}/save") - @ResponseStatus(value = HttpStatus.OK) - public void saveModel(@PathVariable String modelId - , String name, String description - , String json_xml, String svg_xml,HttpServletRequest request, HttpServletResponse response) { - try { - Map map= request.getParameterMap(); - JSONObject jsonObject=new JSONObject(); - //全跑到key了,可取方案 - for(Map.Entry entry:map.entrySet()){ - String data=entry.getKey()+"="+(entry.getValue()[0]); - jsonObject= JSON.parseObject(data); - } - name= (String) jsonObject.get("name"); - description= (String) jsonObject.get("description"); - json_xml= (String) jsonObject.get("json_xml"); - svg_xml= (String) jsonObject.get("svg_xml"); - - Model model = repositoryService.getModel(modelId); - JSONObject object=new JSONObject(); - object.put(MODEL_NAME, name); - object.put(MODEL_DESCRIPTION, description); - model.setMetaInfo(object.toString()); - model.setName(name); - repositoryService.saveModel(model); - - repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8")); - - InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8")); - TranscoderInput input = new TranscoderInput(svgStream); - - PNGTranscoder transcoder = new PNGTranscoder(); - // Setup output - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - TranscoderOutput output = new TranscoderOutput(outStream); - - // Do the transformation - transcoder.transcode(input, output); - final byte[] result = outStream.toByteArray(); - repositoryService.addModelEditorSourceExtra(model.getId(), result); - outStream.close(); - - } catch (Exception e) { - LOGGER.error("Error saving model", e); - throw new ActivitiException("Error saving model", e); - } - } -} +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.activiti.rest.editor.model; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.activiti.editor.constants.ModelDataJsonConstants; +import org.activiti.engine.ActivitiException; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.repository.Model; +import org.apache.batik.transcoder.TranscoderInput; +import org.apache.batik.transcoder.TranscoderOutput; +import org.apache.batik.transcoder.image.PNGTranscoder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; + +/** + * @author Tijs Rademakers + */ +@RestController +@RequestMapping("service") +public class ModelSaveRestResource implements ModelDataJsonConstants { + + protected static final Logger LOGGER = LoggerFactory.getLogger(ModelSaveRestResource.class); + + @Autowired + private RepositoryService repositoryService; + + + @PostMapping(value="/model/{modelId}/save") + @ResponseStatus(value = HttpStatus.OK) + public void saveModel(@PathVariable String modelId + , String name, String description + , String json_xml, String svg_xml,HttpServletRequest request, HttpServletResponse response) { + try { + Map map= request.getParameterMap(); + JSONObject jsonObject=new JSONObject(); + //全跑到key了,可取方案 + for(Map.Entry entry:map.entrySet()){ + String data=entry.getKey()+"="+(entry.getValue()[0]); + jsonObject= JSON.parseObject(data); + } + name= (String) jsonObject.get("name"); + description= (String) jsonObject.get("description"); + json_xml= (String) jsonObject.get("json_xml"); + svg_xml= (String) jsonObject.get("svg_xml"); + + Model model = repositoryService.getModel(modelId); + JSONObject object=new JSONObject(); + object.put(MODEL_NAME, name); + object.put(MODEL_DESCRIPTION, description); + model.setMetaInfo(object.toString()); + model.setName(name); + repositoryService.saveModel(model); + + repositoryService.addModelEditorSource(model.getId(), json_xml.getBytes("utf-8")); + + InputStream svgStream = new ByteArrayInputStream(svg_xml.getBytes("utf-8")); + TranscoderInput input = new TranscoderInput(svgStream); + + PNGTranscoder transcoder = new PNGTranscoder(); + // Setup output + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + TranscoderOutput output = new TranscoderOutput(outStream); + + // Do the transformation + transcoder.transcode(input, output); + final byte[] result = outStream.toByteArray(); + repositoryService.addModelEditorSourceExtra(model.getId(), result); + outStream.close(); + + } catch (Exception e) { + LOGGER.error("Error saving model", e); + throw new ActivitiException("Error saving model", e); + } + } +} diff --git a/len-core/src/main/java/com/len/base/BaseController.java b/len-core/src/main/java/com/len/base/BaseController.java index a868b55..2fca3f6 100644 --- a/len-core/src/main/java/com/len/base/BaseController.java +++ b/len-core/src/main/java/com/len/base/BaseController.java @@ -1,62 +1,62 @@ -package com.len.base; - -import com.len.util.JsonUtil; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.shiro.authz.AuthorizationException; -import org.apache.shiro.authz.UnauthorizedException; -import org.springframework.beans.propertyeditors.CustomDateEditor; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.InitBinder; - -/** - * @author zhuxiaomeng - * @date 2017/12/19. - * @email 154040976@qq.com - */ -public abstract class BaseController { - - @InitBinder - protected void initBinder(WebDataBinder binder) { - binder.registerCustomEditor(Date.class, new CustomDateEditor( - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); - binder.registerCustomEditor(Date.class, new CustomDateEditor( - new SimpleDateFormat("yyyy-MM-dd"), true)); - } - - @ExceptionHandler({ UnauthorizedException.class, AuthorizationException.class }) - public String authorizationException(HttpServletRequest request, HttpServletResponse response) { - if (isAjaxRequest(request)) { - Map map = new HashMap<>(); - map.put("code", "-998"); - map.put("message", "无权限"); - //response.gets - return null; - } else { - String message="权限不足"; - try { - message = URLEncoder.encode(message,"utf-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return "redirect:/error/403?message="+message; - } - } - public static boolean isAjaxRequest(HttpServletRequest request) { - String requestedWith = request.getHeader("x-requested-with"); - if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) { - return true; - } else { - return false; - } - } - - -} +package com.len.base; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.apache.shiro.authz.AuthorizationException; +import org.apache.shiro.authz.UnauthorizedException; +import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.InitBinder; + +import com.google.common.collect.Maps; + +/** + * @author zhuxiaomeng + * @date 2017/12/19. + * @email 154040976@qq.com + */ +public abstract class BaseController { + + @InitBinder + protected void initBinder(WebDataBinder binder) { + binder.registerCustomEditor(Date.class, new CustomDateEditor( + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true)); + binder.registerCustomEditor(Date.class, new CustomDateEditor( + new SimpleDateFormat("yyyy-MM-dd"), true)); + } + + @ExceptionHandler({ UnauthorizedException.class, AuthorizationException.class }) + public String authorizationException(HttpServletRequest request, HttpServletResponse response) { + if (isAjaxRequest(request)) { + Map map = Maps.newHashMap(); + map.put("code", "-998"); + map.put("message", "无权限"); + //response.gets + return null; + } else { + String message="权限不足"; + try { + message = URLEncoder.encode(message,"utf-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return "redirect:/error/403?message="+message; + } + } + public static boolean isAjaxRequest(HttpServletRequest request) { + String requestedWith = request.getHeader("x-requested-with"); + if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) { + return true; + } else { + return false; + } + } + + +} diff --git a/len-core/src/main/java/com/len/base/CurrentMenu.java b/len-core/src/main/java/com/len/base/CurrentMenu.java index c76bc58..5aec787 100644 --- a/len-core/src/main/java/com/len/base/CurrentMenu.java +++ b/len-core/src/main/java/com/len/base/CurrentMenu.java @@ -1,54 +1,60 @@ -package com.len.base; - -import java.util.Date; -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * @author zhuxiaomeng - * @date 2017/12/30. - * @email 154040976@qq.com - */ -@Getter -@Setter -@ToString -public class CurrentMenu { - private String id; - - private String name; - - private String pId; - - private String url; - - private Integer orderNum; - - private String icon; - - private String createBy; - - private Date createDate; - - private String updateBy; - - private Date updateDate; - - private String permission; - - private Byte menuType; - /**菜单排序id 填充菜单展示id*/ - private int num; - - public CurrentMenu(String id, String name, String pId, String url, Integer orderNum, String icon, String permission, Byte menuType, int num) { - this.id = id; - this.name = name; - this.pId = pId; - this.url = url; - this.orderNum = orderNum; - this.icon = icon; - this.permission = permission; - this.menuType = menuType; - this.num = num; - } -} +package com.len.base; + +import java.io.Serializable; +import java.util.Date; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author zhuxiaomeng + * @date 2017/12/30. + * @email 154040976@qq.com + */ +@Getter +@Setter +@ToString +public class CurrentMenu implements Serializable { + /** + * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) + */ + private static final long serialVersionUID = 1L; + + private String id; + + private String name; + + private String pId; + + private String url; + + private Integer orderNum; + + private String icon; + + private String createBy; + + private Date createDate; + + private String updateBy; + + private Date updateDate; + + private String permission; + + private Byte menuType; + /**菜单排序id 填充菜单展示id*/ + private int num; + + public CurrentMenu(String id, String name, String pId, String url, Integer orderNum, String icon, String permission, Byte menuType, int num) { + this.id = id; + this.name = name; + this.pId = pId; + this.url = url; + this.orderNum = orderNum; + this.icon = icon; + this.permission = permission; + this.menuType = menuType; + this.num = num; + } +} diff --git a/len-core/src/main/java/com/len/base/CurrentRole.java b/len-core/src/main/java/com/len/base/CurrentRole.java index f8a3e29..23618c7 100644 --- a/len-core/src/main/java/com/len/base/CurrentRole.java +++ b/len-core/src/main/java/com/len/base/CurrentRole.java @@ -1,28 +1,35 @@ -package com.len.base; - -import lombok.Getter; -import lombok.Setter; -import lombok.ToString; - -/** - * @author zhuxiaomeng - * @date 2017/12/30. - * @email 154040976@qq.com - */ -@Getter -@Setter -@ToString -public class CurrentRole { - - private String id; - - private String roleName; - - private String remark; - - public CurrentRole(String id, String roleName, String remark) { - this.id = id; - this.roleName = roleName; - this.remark = remark; - } -} +package com.len.base; + +import java.io.Serializable; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author zhuxiaomeng + * @date 2017/12/30. + * @email 154040976@qq.com + */ +@Getter +@Setter +@ToString +public class CurrentRole implements Serializable { + + /** + * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么) + */ + private static final long serialVersionUID = 1L; + + private String id; + + private String roleName; + + private String remark; + + public CurrentRole(String id, String roleName, String remark) { + this.id = id; + this.roleName = roleName; + this.remark = remark; + } +} diff --git a/len-sys/src/main/java/com/len/controller/MenuController.java b/len-sys/src/main/java/com/len/controller/MenuController.java index 8fc71f6..05f1c0a 100644 --- a/len-sys/src/main/java/com/len/controller/MenuController.java +++ b/len-sys/src/main/java/com/len/controller/MenuController.java @@ -1,116 +1,117 @@ -package com.len.controller; - -import com.alibaba.fastjson.JSONArray; -import com.len.base.BaseController; -import com.len.core.annotation.Log; -import com.len.core.annotation.Log.LOG_TYPE; -import com.len.entity.SysMenu; -import com.len.exception.MyException; -import com.len.service.MenuService; -import com.len.util.BeanUtil; -import com.len.util.JsonUtil; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * @author zhuxiaomeng - * @date 2017/12/13. - * @email 154040976@qq.com - * 菜单 - */ -@RequestMapping("/menu") -@Controller -public class MenuController extends BaseController{ - - @Autowired - private MenuService menuService; - - /** - * 展示tree - * @param model - * @return - */ - @ApiOperation(value = "/showMenu", httpMethod = "GET", notes = "展示菜单") - @Log(desc = "展示菜单",type = Log.LOG_TYPE.SELECT) - @GetMapping(value = "showMenu") - @RequiresPermissions("menu:show") - public String showMenu(Model model){ - JSONArray ja=menuService.getMenuJsonList(); - model.addAttribute("menus", ja.toJSONString()); - return "/system/menu/menuList"; - } - - @GetMapping(value = "showAddMenu") - public String addMenu(Model model){ - JSONArray ja=menuService.getMenuJsonList(); - System.out.print(ja.toJSONString()); - model.addAttribute("menus", ja.toJSONString()); - return "/system/menu/add-menu"; - } - - @Log(desc = "添加菜单",type = LOG_TYPE.UPDATE) - @ApiOperation(value = "/addMenu", httpMethod = "POST", notes = "添加菜单") - @PostMapping(value = "addMenu") - @ResponseBody - public JsonUtil addMenu(SysMenu sysMenu,Model model){ - if(StringUtils.isEmpty(sysMenu.getPId())){ - sysMenu.setPId(null); - } - if(StringUtils.isEmpty(sysMenu.getUrl())){ - sysMenu.setUrl(null); - } - if(StringUtils.isEmpty(sysMenu.getPermission())){ - sysMenu.setPermission(null); - } - JsonUtil jsonUtil=new JsonUtil(); - jsonUtil.setFlag(false); - if(sysMenu==null){ - jsonUtil.setMsg("获取数据失败"); - return jsonUtil; - } - try{ - if(sysMenu.getMenuType()==2){ - sysMenu.setMenuType((byte)0); - } - menuService.insertSelective(sysMenu); - jsonUtil.setMsg("添加成功"); - }catch (MyException e){ - e.printStackTrace(); - jsonUtil.setMsg("添加失败"); - } - return jsonUtil; - } - - @GetMapping(value = "showUpdateMenu") - public String showUpdateMenu(Model model,String id){ - SysMenu sysMenu = menuService.selectByPrimaryKey(id); - JSONArray ja=menuService.getMenuJsonList(); - model.addAttribute("menus", ja.toJSONString()); - model.addAttribute("sysMenu", sysMenu); - if(null!=sysMenu.getPId()){ - SysMenu pSysMenu=menuService.selectByPrimaryKey(sysMenu.getPId()); - model.addAttribute("pName", pSysMenu.getName()); - } - return "/system/menu/update-menu"; - } - - - @Log(desc = "更新菜单",type = LOG_TYPE.ADD) - @PostMapping(value = "updateMenu") - @ResponseBody - public JsonUtil updateMenu(SysMenu sysMenu){ - SysMenu oldMenu = menuService.selectByPrimaryKey(sysMenu.getId()); - BeanUtil.copyNotNullBean(sysMenu,oldMenu); - menuService.updateByPrimaryKeySelective(oldMenu); - return JsonUtil.sucess("保存成功"); - } - -} +package com.len.controller; + +import com.alibaba.fastjson.JSONArray; +import com.len.base.BaseController; +import com.len.core.annotation.Log; +import com.len.core.annotation.Log.LOG_TYPE; +import com.len.entity.SysMenu; +import com.len.exception.MyException; +import com.len.service.MenuService; +import com.len.util.BeanUtil; +import com.len.util.JsonUtil; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author zhuxiaomeng + * @date 2017/12/13. + * @email 154040976@qq.com + * 菜单 + */ +@RequestMapping("/menu") +@Controller +public class MenuController extends BaseController{ + + @Autowired + private MenuService menuService; + + /** + * 展示tree + * @param model + * @return + */ + @ApiOperation(value = "/showMenu", httpMethod = "GET", notes = "展示菜单") + @Log(desc = "展示菜单",type = Log.LOG_TYPE.SELECT) + @GetMapping(value = "showMenu") + @RequiresPermissions("menu:show") + public String showMenu(Model model){ + JSONArray ja=menuService.getMenuJsonList(); + model.addAttribute("menus", ja.toJSONString()); + return "/system/menu/menuList"; + } + + @GetMapping(value = "showAddMenu") + public String addMenu(Model model){ + JSONArray ja=menuService.getMenuJsonList(); + System.out.print(ja.toJSONString()); + model.addAttribute("menus", ja.toJSONString()); + return "/system/menu/add-menu"; + } + + @Log(desc = "添加菜单",type = LOG_TYPE.UPDATE) + @ApiOperation(value = "/addMenu", httpMethod = "POST", notes = "添加菜单") + @PostMapping(value = "addMenu") + @ResponseBody + public JsonUtil addMenu(SysMenu sysMenu,Model model){ + JsonUtil jsonUtil=new JsonUtil(); + jsonUtil.setFlag(false); + if(sysMenu==null){ + jsonUtil.setMsg("获取数据失败"); + return jsonUtil; + } + if(StringUtils.isEmpty(sysMenu.getPId())){ + sysMenu.setPId(null); + } + if(StringUtils.isEmpty(sysMenu.getUrl())){ + sysMenu.setUrl(null); + } + if(StringUtils.isEmpty(sysMenu.getPermission())){ + sysMenu.setPermission(null); + } + + try{ + if(sysMenu.getMenuType()==2){ + sysMenu.setMenuType((byte)0); + } + menuService.insertSelective(sysMenu); + jsonUtil.setMsg("添加成功"); + }catch (MyException e){ + e.printStackTrace(); + jsonUtil.setMsg("添加失败"); + } + return jsonUtil; + } + + @GetMapping(value = "showUpdateMenu") + public String showUpdateMenu(Model model,String id){ + SysMenu sysMenu = menuService.selectByPrimaryKey(id); + JSONArray ja=menuService.getMenuJsonList(); + model.addAttribute("menus", ja.toJSONString()); + model.addAttribute("sysMenu", sysMenu); + if(null!=sysMenu.getPId()){ + SysMenu pSysMenu=menuService.selectByPrimaryKey(sysMenu.getPId()); + model.addAttribute("pName", pSysMenu.getName()); + } + return "/system/menu/update-menu"; + } + + + @Log(desc = "更新菜单",type = LOG_TYPE.ADD) + @PostMapping(value = "updateMenu") + @ResponseBody + public JsonUtil updateMenu(SysMenu sysMenu){ + SysMenu oldMenu = menuService.selectByPrimaryKey(sysMenu.getId()); + BeanUtil.copyNotNullBean(sysMenu,oldMenu); + menuService.updateByPrimaryKeySelective(oldMenu); + return JsonUtil.sucess("保存成功"); + } + +} diff --git a/len-sys/src/main/java/com/len/core/shiro/RetryLimitCredentialsMatcher.java b/len-sys/src/main/java/com/len/core/shiro/RetryLimitCredentialsMatcher.java index c264474..fd0d66e 100644 --- a/len-sys/src/main/java/com/len/core/shiro/RetryLimitCredentialsMatcher.java +++ b/len-sys/src/main/java/com/len/core/shiro/RetryLimitCredentialsMatcher.java @@ -1,65 +1,65 @@ -package com.len.core.shiro; - -import java.util.concurrent.atomic.AtomicInteger; -import org.apache.shiro.authc.AuthenticationInfo; -import org.apache.shiro.authc.AuthenticationToken; -import org.apache.shiro.authc.ExcessiveAttemptsException; -import org.apache.shiro.authc.credential.HashedCredentialsMatcher; -import org.apache.shiro.cache.Cache; -import org.apache.shiro.cache.CacheManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 验证器,增加了登录次数校验功能 - * 限制尝试登陆次数,防止暴力破解 - */ -public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher { - private static final Logger log = LoggerFactory.getLogger(RetryLimitCredentialsMatcher.class); - - private Cache loginRetryCache; - - private int maxRetryCount = 5; - - private String loginRetryCacheName; - - public void setMaxRetryCount(int maxRetryCount) { - this.maxRetryCount = maxRetryCount; - } - - /** - * - * @param cacheManager - * @param maxRetryCount 最大尝试次数 - */ - public RetryLimitCredentialsMatcher(CacheManager cacheManager,int maxRetryCount) { - this.maxRetryCount = maxRetryCount; - loginRetryCache = cacheManager.getCache("loginRetryCache");//尝试获取cache,没有则新建 - } - - public RetryLimitCredentialsMatcher(CacheManager cacheManager){ - this(cacheManager,5); - } - - @Override - public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { - String username = (String) token.getPrincipal(); - //retry count + 1 - AtomicInteger retryCount = loginRetryCache.get(username) == null - ? new AtomicInteger(0) : loginRetryCache.get(username); - log.info("retryCount:{}, username:{}",retryCount,username); - if (retryCount.incrementAndGet() > this.maxRetryCount) { - log.warn("username: {} tried to login more than {} times in perid", username,this.maxRetryCount); - throw new ExcessiveAttemptsException(String.format("username: {} tried to login more than {} times in perid", username,this.maxRetryCount)); - } - boolean matches = super.doCredentialsMatch(token, info); - - if (matches) { - loginRetryCache.remove(username); - } else { - loginRetryCache.put(username, retryCount); - log.info(String.valueOf(retryCount.get())); - } - return matches; - } +package com.len.core.shiro; + +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.ExcessiveAttemptsException; +import org.apache.shiro.authc.credential.HashedCredentialsMatcher; +import org.apache.shiro.cache.Cache; +import org.apache.shiro.cache.CacheManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import cn.hutool.core.util.StrUtil; + +/** + * 验证器,增加了登录次数校验功能 + * 限制尝试登陆次数,防止暴力破解 + */ +public class RetryLimitCredentialsMatcher extends HashedCredentialsMatcher { + private static final Logger log = LoggerFactory.getLogger(RetryLimitCredentialsMatcher.class); + + private Cache loginRetryCache; + + private int maxRetryCount = 5; + + public void setMaxRetryCount(int maxRetryCount) { + this.maxRetryCount = maxRetryCount; + } + + /** + * + * @param cacheManager + * @param maxRetryCount 最大尝试次数 + */ + public RetryLimitCredentialsMatcher(CacheManager cacheManager,int maxRetryCount) { + this.maxRetryCount = maxRetryCount; + loginRetryCache = cacheManager.getCache("loginRetryCache");//尝试获取cache,没有则新建 + } + + public RetryLimitCredentialsMatcher(CacheManager cacheManager){ + this(cacheManager,5); + } + + @Override + public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { + String username = (String) token.getPrincipal(); + //retry count + 1 + AtomicInteger retryCount = loginRetryCache.get(username) == null + ? new AtomicInteger(0) : loginRetryCache.get(username); + log.info("retryCount:{}, username:{}",retryCount,username); + if (retryCount.incrementAndGet() > this.maxRetryCount) { + log.warn("username: {} tried to login more than {} times in perid", username,this.maxRetryCount); + throw new ExcessiveAttemptsException(StrUtil.format("username: {} tried to login more than {} times in perid", username,this.maxRetryCount)); + } + boolean matches = super.doCredentialsMatch(token, info); + + if (matches) { + loginRetryCache.remove(username); + } else { + loginRetryCache.put(username, retryCount); + log.info(String.valueOf(retryCount.get())); + } + return matches; + } } \ No newline at end of file diff --git a/len-sys/src/main/java/com/len/service/impl/MenuServiceImpl.java b/len-sys/src/main/java/com/len/service/impl/MenuServiceImpl.java index adeb988..731c178 100644 --- a/len-sys/src/main/java/com/len/service/impl/MenuServiceImpl.java +++ b/len-sys/src/main/java/com/len/service/impl/MenuServiceImpl.java @@ -1,209 +1,209 @@ -package com.len.service.impl; - -import com.alibaba.fastjson.JSONArray; -import com.len.base.BaseMapper; -import com.len.base.impl.BaseServiceImpl; -import com.len.entity.SysMenu; -import com.len.entity.SysRoleMenu; -import com.len.mapper.SysMenuMapper; -import com.len.mapper.SysRoleMenuMapper; -import com.len.service.MenuService; -import com.len.service.SysUserService; -import com.len.util.TreeUtil; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author zhuxiaomeng - * @date 2017/12/12. - * @email 154040976@qq.com - */ -@Service -public class MenuServiceImpl extends BaseServiceImpl implements MenuService { - - @Autowired - private SysMenuMapper menuDao; - - @Autowired - private SysUserService userService; - - @Autowired - private SysRoleMenuMapper roleMenuMapper; - - @Override - public BaseMapper getMappser() { - return menuDao; - } - - @Override - public List getMenuNotSuper() { - return menuDao.getMenuNotSuper(); - } - - @Override - public int insert(SysMenu menu) { - return menuDao.insert(menu); - } - - @Override - public SysMenu selectByPrimaryKey(String id) { - return menuDao.selectByPrimaryKey(id); - } - - @Override - public List getMenuChildren(String id) { - return menuDao.getMenuChildren(id); - } - - @Override - public JSONArray getMenuJson(String roleId){ - List mList=menuDao.getMenuNotSuper(); - JSONArray jsonArr=new JSONArray(); - int pNum=1000,num=0; - for(SysMenu sysMenu:mList){ - SysMenu menu=getChild(sysMenu.getId(),true,pNum,num); - jsonArr.add(menu); - pNum+=1000; - } - System.out.println(jsonArr); - return jsonArr; - } - - @Override - public JSONArray getMenuJsonList() { - List mList=menuDao.getMenuNotSuper(); - JSONArray jsonArr=new JSONArray(); - for(SysMenu sysMenu:mList){ - SysMenu menu=getChild(sysMenu.getId(),false,0,0); - jsonArr.add(menu); - } - System.out.println(jsonArr); - return jsonArr; - } - - @Override - public JSONArray getMenuJsonByUser(List menuList){ - //List menuListOne=new ArrayList<>();//获取第一级别 - JSONArray jsonArr=new JSONArray(); - Collections.sort(menuList, new Comparator() { - @Override - public int compare(SysMenu o1, SysMenu o2) { - if(o1.getOrderNum()==null||o2.getOrderNum()==null){ - return -1; - } - if(o1.getOrderNum()>o2.getOrderNum()){ - return 1; - } - if(o1.getOrderNum()==o2.getOrderNum()){ - return 0; - } - return -1; - } - }); - int pNum=1000; - for(SysMenu menu:menuList){ - if(StringUtils.isEmpty(menu.getPId())){ - SysMenu sysMenu=getChilds(menu,pNum,0,menuList); - jsonArr.add(sysMenu); - pNum+=1000; - } - } - return jsonArr; - } - - public SysMenu getChilds(SysMenu menu,int pNum,int num,List menuList){ - for(SysMenu menus:menuList){ - if(menu.getId().equals(menus.getPId())&&menus.getMenuType()==0){ - ++num; - SysMenu m=getChilds(menus,pNum,num,menuList); - m.setNum(pNum+num); - menu.addChild(m); - } - } - return menu; - - } - @Override - public List getMenuChildrenAll(String id) { - return menuDao.getMenuChildrenAll(id); - } - - /** - * - * @param id 父菜单id - * @param flag true 获取非按钮菜单 false 获取包括按钮在内菜单 用于nemuList展示 - * @param pNum 用户控制侧拉不重复id tab 父循环+1000 - * @param num 用户控制侧拉不重复id tab 最终效果 1001 10002 2001 2002 - * @return - */ - public SysMenu getChild(String id,boolean flag,int pNum,int num){ - SysMenu sysMenu=menuDao.selectByPrimaryKey(id); - List mList=null; - if(flag){ - mList= menuDao.getMenuChildren(id); - }else{ - mList=menuDao.getMenuChildrenAll(id); - } - for(SysMenu menu:mList){ - ++num; - SysMenu m=getChild(menu.getId(),flag,pNum,num); - if(flag) - m.setNum(pNum+num); - sysMenu.addChild(m); - } - return sysMenu; - } - - @Override - public JSONArray getTreeUtil(String roleId){ - TreeUtil treeUtil=null; - List mList=menuDao.getMenuNotSuper(); - JSONArray jsonArr=new JSONArray(); - for(SysMenu sysMenu:mList){ - treeUtil=getChildByTree(sysMenu.getId(),false,0,null,roleId); - jsonArr.add(treeUtil); - } - System.out.println(jsonArr); - return jsonArr; - - } - - @Override - public List getUserMenu(String id) { - return menuDao.getUserMenu(id); - } - - public TreeUtil getChildByTree(String id,boolean flag,int layer,String pId,String roleId){ - layer++; - SysMenu sysMenu=menuDao.selectByPrimaryKey(id); - List mList=null; - if(flag){ - mList= menuDao.getMenuChildren(id); - }else{ - mList=menuDao.getMenuChildrenAll(id); - } - TreeUtil treeUtil = new TreeUtil(); - treeUtil.setId(sysMenu.getId()); - treeUtil.setName(sysMenu.getName()); - treeUtil.setLayer(layer); - treeUtil.setPId(pId); - /**判断是否存在*/ - if(!StringUtils.isEmpty(roleId)){ - SysRoleMenu sysRoleMenu = new SysRoleMenu(); - sysRoleMenu.setMenuId(sysMenu.getId()); - sysRoleMenu.setRoleId(roleId); - int count = roleMenuMapper.selectCountByCondition(sysRoleMenu); - if (count > 0) - treeUtil.setChecked(true); - } - for(SysMenu menu:mList){ - TreeUtil m=getChildByTree(menu.getId(),flag,layer,menu.getId(),roleId); - treeUtil.getChildren().add(m); - } - return treeUtil; - } -} +package com.len.service.impl; + +import com.alibaba.fastjson.JSONArray; +import com.len.base.BaseMapper; +import com.len.base.impl.BaseServiceImpl; +import com.len.entity.SysMenu; +import com.len.entity.SysRoleMenu; +import com.len.mapper.SysMenuMapper; +import com.len.mapper.SysRoleMenuMapper; +import com.len.service.MenuService; +import com.len.service.SysUserService; +import com.len.util.TreeUtil; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author zhuxiaomeng + * @date 2017/12/12. + * @email 154040976@qq.com + */ +@Service +public class MenuServiceImpl extends BaseServiceImpl implements MenuService { + + @Autowired + private SysMenuMapper menuDao; + + @Autowired + private SysUserService userService; + + @Autowired + private SysRoleMenuMapper roleMenuMapper; + + @Override + public BaseMapper getMappser() { + return menuDao; + } + + @Override + public List getMenuNotSuper() { + return menuDao.getMenuNotSuper(); + } + + @Override + public int insert(SysMenu menu) { + return menuDao.insert(menu); + } + + @Override + public SysMenu selectByPrimaryKey(String id) { + return menuDao.selectByPrimaryKey(id); + } + + @Override + public List getMenuChildren(String id) { + return menuDao.getMenuChildren(id); + } + + @Override + public JSONArray getMenuJson(String roleId){ + List mList=menuDao.getMenuNotSuper(); + JSONArray jsonArr=new JSONArray(); + int pNum=1000,num=0; + for(SysMenu sysMenu:mList){ + SysMenu menu=getChild(sysMenu.getId(),true,pNum,num); + jsonArr.add(menu); + pNum+=1000; + } + System.out.println(jsonArr); + return jsonArr; + } + + @Override + public JSONArray getMenuJsonList() { + List mList=menuDao.getMenuNotSuper(); + JSONArray jsonArr=new JSONArray(); + for(SysMenu sysMenu:mList){ + SysMenu menu=getChild(sysMenu.getId(),false,0,0); + jsonArr.add(menu); + } + System.out.println(jsonArr); + return jsonArr; + } + + @Override + public JSONArray getMenuJsonByUser(List menuList){ + //List menuListOne=new ArrayList<>();//获取第一级别 + JSONArray jsonArr=new JSONArray(); + Collections.sort(menuList, new Comparator() { + @Override + public int compare(SysMenu o1, SysMenu o2) { + if(o1.getOrderNum()==null||o2.getOrderNum()==null){ + return -1; + } + if(o1.getOrderNum()>o2.getOrderNum()){ + return 1; + } + if(o1.getOrderNum().equals(o2.getOrderNum())){ + return 0; + } + return -1; + } + }); + int pNum=1000; + for(SysMenu menu:menuList){ + if(StringUtils.isEmpty(menu.getPId())){ + SysMenu sysMenu=getChilds(menu,pNum,0,menuList); + jsonArr.add(sysMenu); + pNum+=1000; + } + } + return jsonArr; + } + + public SysMenu getChilds(SysMenu menu,int pNum,int num,List menuList){ + for(SysMenu menus:menuList){ + if(menu.getId().equals(menus.getPId())&&menus.getMenuType()==0){ + ++num; + SysMenu m=getChilds(menus,pNum,num,menuList); + m.setNum(pNum+num); + menu.addChild(m); + } + } + return menu; + + } + @Override + public List getMenuChildrenAll(String id) { + return menuDao.getMenuChildrenAll(id); + } + + /** + * + * @param id 父菜单id + * @param flag true 获取非按钮菜单 false 获取包括按钮在内菜单 用于nemuList展示 + * @param pNum 用户控制侧拉不重复id tab 父循环+1000 + * @param num 用户控制侧拉不重复id tab 最终效果 1001 10002 2001 2002 + * @return + */ + public SysMenu getChild(String id,boolean flag,int pNum,int num){ + SysMenu sysMenu=menuDao.selectByPrimaryKey(id); + List mList=null; + if(flag){ + mList= menuDao.getMenuChildren(id); + }else{ + mList=menuDao.getMenuChildrenAll(id); + } + for(SysMenu menu:mList){ + ++num; + SysMenu m=getChild(menu.getId(),flag,pNum,num); + if(flag) + m.setNum(pNum+num); + sysMenu.addChild(m); + } + return sysMenu; + } + + @Override + public JSONArray getTreeUtil(String roleId){ + TreeUtil treeUtil=null; + List mList=menuDao.getMenuNotSuper(); + JSONArray jsonArr=new JSONArray(); + for(SysMenu sysMenu:mList){ + treeUtil=getChildByTree(sysMenu.getId(),false,0,null,roleId); + jsonArr.add(treeUtil); + } + System.out.println(jsonArr); + return jsonArr; + + } + + @Override + public List getUserMenu(String id) { + return menuDao.getUserMenu(id); + } + + public TreeUtil getChildByTree(String id,boolean flag,int layer,String pId,String roleId){ + layer++; + SysMenu sysMenu=menuDao.selectByPrimaryKey(id); + List mList=null; + if(flag){ + mList= menuDao.getMenuChildren(id); + }else{ + mList=menuDao.getMenuChildrenAll(id); + } + TreeUtil treeUtil = new TreeUtil(); + treeUtil.setId(sysMenu.getId()); + treeUtil.setName(sysMenu.getName()); + treeUtil.setLayer(layer); + treeUtil.setPId(pId); + /**判断是否存在*/ + if(!StringUtils.isEmpty(roleId)){ + SysRoleMenu sysRoleMenu = new SysRoleMenu(); + sysRoleMenu.setMenuId(sysMenu.getId()); + sysRoleMenu.setRoleId(roleId); + int count = roleMenuMapper.selectCountByCondition(sysRoleMenu); + if (count > 0) + treeUtil.setChecked(true); + } + for(SysMenu menu:mList){ + TreeUtil m=getChildByTree(menu.getId(),flag,layer,menu.getId(),roleId); + treeUtil.getChildren().add(m); + } + return treeUtil; + } +} diff --git a/len-sys/src/main/java/com/len/service/impl/SysUserServiceImpl.java b/len-sys/src/main/java/com/len/service/impl/SysUserServiceImpl.java index 9c7d8d1..9b4dd3b 100644 --- a/len-sys/src/main/java/com/len/service/impl/SysUserServiceImpl.java +++ b/len-sys/src/main/java/com/len/service/impl/SysUserServiceImpl.java @@ -1,183 +1,181 @@ -package com.len.service.impl; - -import com.len.base.BaseMapper; -import com.len.base.impl.BaseServiceImpl; -import com.len.entity.SysRole; -import com.len.entity.SysRoleUser; -import com.len.entity.SysUser; -import com.len.exception.MyException; -import com.len.mapper.SysRoleUserMapper; -import com.len.mapper.SysUserMapper; -import com.len.service.RoleService; -import com.len.service.RoleUserService; -import com.len.service.SysUserService; -import com.len.util.Checkbox; -import com.len.util.JsonUtil; -import com.len.util.Md5Util; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * @author zhuxiaomeng - * @date 2017/12/4. - * @email 154040976@qq.com - */ -@Service -public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService { - - @Autowired - SysUserMapper sysUserMapper; - - @Autowired - SysRoleUserMapper sysRoleUserMapper; - - @Autowired - RoleService roleService; - - @Autowired - RoleUserService roleUserService; - @Override - public BaseMapper getMappser() { - return sysUserMapper; - } - - @Override - public SysUser login(String username) { - return sysUserMapper.login(username); - } - - - @Override - public int deleteByPrimaryKey(String id) { - return sysUserMapper.deleteByPrimaryKey(id); - } - - @Override - public int insert(SysUser record) { - return sysUserMapper.insert(record); - } - - @Override - public int insertSelective(SysUser record) { - - String pwd= Md5Util.getMD5(record.getPassword().trim(),record.getUsername().trim()); - record.setPassword(pwd); - return super.insertSelective(record); - } - - @Override - public SysUser selectByPrimaryKey(String id) { - return sysUserMapper.selectByPrimaryKey(id); - } - - @Override - public int updateByPrimaryKeySelective(SysUser record) { - return super.updateByPrimaryKeySelective(record); - } - - @Override - public int updateByPrimaryKey(SysUser record) { - return sysUserMapper.updateByPrimaryKey(record); - } - - @Override - public List selectByCondition(SysRoleUser sysRoleUser) { - return sysRoleUserMapper.selectByCondition(sysRoleUser); - } - - /** - * 分页查询 - * @param - * @return - */ - @Override - public List selectListByPage(SysUser sysUser) { - return sysUserMapper.selectListByPage(sysUser); - } - - @Override - public int count() { - return sysUserMapper.count(); - } - - @Override - public int add(SysUser user) { - //密码加密 - String pwd= Md5Util.getMD5(user.getPassword().trim(),user.getUsername().trim()); - user.setPassword(pwd); - return sysUserMapper.add(user); - } - - @Override - public JsonUtil delById(String id,boolean flag) { - if (StringUtils.isEmpty(id)) { - return JsonUtil.error("获取数据失败"); - } - JsonUtil j=null; - try { - SysUser sysUser = selectByPrimaryKey(id); - if("admin".equals(sysUser.getUsername())){ - return JsonUtil.error("超管无法删除"); - } - SysRoleUser roleUser=new SysRoleUser(); - roleUser.setUserId(id); - int count=roleUserService.selectCountByCondition(roleUser); - if(count>0){ - return JsonUtil.error("账户已经绑定角色,无法删除"); - } - j=new JsonUtil(); - if (flag) { - //逻辑 - sysUser.setDelFlag(Byte.parseByte("1")); - updateByPrimaryKeySelective(sysUser); - } else { - //物理 - sysUserMapper.delById(id); - } - j.setMsg("删除成功"); - } catch (MyException e) { - j.setMsg("删除失败"); - j.setFlag(false); - e.printStackTrace(); - } - return j; - - } - - @Override - public int checkUser(String username) { - return sysUserMapper.checkUser(username); - } - - @Override - public List getUserRoleByJson(String id){ - List roleList=roleService.selectListByPage(new SysRole()); - SysRoleUser sysRoleUser =new SysRoleUser(); - sysRoleUser.setUserId(id); - List kList= selectByCondition(sysRoleUser); - System.out.println(kList.size()); - List checkboxList=new ArrayList<>(); - Checkbox checkbox=null; - for(SysRole sysRole:roleList){ - checkbox=new Checkbox(); - checkbox.setId(sysRole.getId()); - checkbox.setName(sysRole.getRoleName()); - for(SysRoleUser sysRoleUser1 :kList){ - if(sysRoleUser1.getRoleId().equals(sysRole.getId())){ - checkbox.setCheck(true); - } - } - checkboxList.add(checkbox); - } - return checkboxList; - } - - @Override - public int rePass(SysUser user) { - return sysUserMapper.rePass(user); - } -} +package com.len.service.impl; + +import com.len.base.BaseMapper; +import com.len.base.impl.BaseServiceImpl; +import com.len.entity.SysRole; +import com.len.entity.SysRoleUser; +import com.len.entity.SysUser; +import com.len.exception.MyException; +import com.len.mapper.SysRoleUserMapper; +import com.len.mapper.SysUserMapper; +import com.len.service.RoleService; +import com.len.service.RoleUserService; +import com.len.service.SysUserService; +import com.len.util.Checkbox; +import com.len.util.JsonUtil; +import com.len.util.Md5Util; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author zhuxiaomeng + * @date 2017/12/4. + * @email 154040976@qq.com + */ +@Service +public class SysUserServiceImpl extends BaseServiceImpl implements SysUserService { + + @Autowired + SysUserMapper sysUserMapper; + + @Autowired + SysRoleUserMapper sysRoleUserMapper; + + @Autowired + RoleService roleService; + + @Autowired + RoleUserService roleUserService; + @Override + public BaseMapper getMappser() { + return sysUserMapper; + } + + @Override + public SysUser login(String username) { + return sysUserMapper.login(username); + } + + + @Override + public int deleteByPrimaryKey(String id) { + return sysUserMapper.deleteByPrimaryKey(id); + } + + @Override + public int insert(SysUser record) { + return sysUserMapper.insert(record); + } + + @Override + public int insertSelective(SysUser record) { + + String pwd= Md5Util.getMD5(record.getPassword().trim(),record.getUsername().trim()); + record.setPassword(pwd); + return super.insertSelective(record); + } + + @Override + public SysUser selectByPrimaryKey(String id) { + return sysUserMapper.selectByPrimaryKey(id); + } + + @Override + public int updateByPrimaryKeySelective(SysUser record) { + return super.updateByPrimaryKeySelective(record); + } + + @Override + public int updateByPrimaryKey(SysUser record) { + return sysUserMapper.updateByPrimaryKey(record); + } + + @Override + public List selectByCondition(SysRoleUser sysRoleUser) { + return sysRoleUserMapper.selectByCondition(sysRoleUser); + } + + /** + * 分页查询 + * @param + * @return + */ + @Override + public List selectListByPage(SysUser sysUser) { + return sysUserMapper.selectListByPage(sysUser); + } + + @Override + public int count() { + return sysUserMapper.count(); + } + + @Override + public int add(SysUser user) { + //密码加密 + String pwd= Md5Util.getMD5(user.getPassword().trim(),user.getUsername().trim()); + user.setPassword(pwd); + return sysUserMapper.add(user); + } + + @Override + public JsonUtil delById(String id,boolean flag) { + if (StringUtils.isEmpty(id)) { + return JsonUtil.error("获取数据失败"); + } + JsonUtil j=new JsonUtil(); + try { + SysUser sysUser = selectByPrimaryKey(id); + if("admin".equals(sysUser.getUsername())){ + return JsonUtil.error("超管无法删除"); + } + SysRoleUser roleUser=new SysRoleUser(); + roleUser.setUserId(id); + int count=roleUserService.selectCountByCondition(roleUser); + if(count>0){ + return JsonUtil.error("账户已经绑定角色,无法删除"); + } + if (flag) { + //逻辑 + sysUser.setDelFlag(Byte.parseByte("1")); + updateByPrimaryKeySelective(sysUser); + } else { + //物理 + sysUserMapper.delById(id); + } + j.setMsg("删除成功"); + } catch (MyException e) { + j.setMsg("删除失败"); + j.setFlag(false); + e.printStackTrace(); + } + return j; + + } + + @Override + public int checkUser(String username) { + return sysUserMapper.checkUser(username); + } + + @Override + public List getUserRoleByJson(String id){ + List roleList=roleService.selectListByPage(new SysRole()); + SysRoleUser sysRoleUser =new SysRoleUser(); + sysRoleUser.setUserId(id); + List kList= selectByCondition(sysRoleUser); + System.out.println(kList.size()); + List checkboxList=new ArrayList<>(); + Checkbox checkbox=null; + for(SysRole sysRole:roleList){ + checkbox=new Checkbox(); + checkbox.setId(sysRole.getId()); + checkbox.setName(sysRole.getRoleName()); + for(SysRoleUser sysRoleUser1 :kList){ + if(sysRoleUser1.getRoleId().equals(sysRole.getId())){ + checkbox.setCheck(true); + } + } + checkboxList.add(checkbox); + } + return checkboxList; + } + + @Override + public int rePass(SysUser user) { + return sysUserMapper.rePass(user); + } +} diff --git a/pom.xml b/pom.xml index 97657b5..0a76ff0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,352 +1,358 @@ - - - 4.0.0 - - com.len - lenosp - pom - 1.0-SNAPSHOT - - org.springframework.boot - spring-boot-starter-parent - 1.5.9.RELEASE - - - - UTF-8 - 1.8 - - - - len-core - len-sys - len-web - len-activiti - - - - - - org.springframework.boot - spring-boot-starter-test - - - junit - junit - 4.12 - - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 1.3.1 - - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.springframework.boot - spring-boot-starter-aop - - - - org.springframework.boot - spring-boot-starter-freemarker - - - - - - - mysql - mysql-connector-java - 5.1.6 - - - - - com.alibaba - druid - 1.0.24 - - - - - org.mybatis - mybatis-spring - 1.3.0 - - - - - com.github.pagehelper - pagehelper - 5.1.2 - - - com.github.pagehelper - pagehelper-spring-boot-autoconfigure - 1.2.3 - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.3 - - - - org.mybatis - mybatis - 3.4.1 - - - - - ehcache-core - net.sf.ehcache - 2.5.0 - - - org.apache.shiro - shiro-ehcache - 1.2.2 - - - - - org.apache.shiro - shiro-aspectj - 1.4.0 - - - - - - org.slf4j - slf4j-api - 1.7.25 - - - - - org.apache.shiro - shiro-core - 1.2.3 - - - - - org.projectlombok - lombok - 1.16.10 - provided - - - - org.apache.shiro - shiro-web - 1.2.3 - - - org.apache.shiro - shiro-spring - 1.2.3 - - - - net.mingsoft - shiro-freemarker-tags - 0.1 - - - - - org.apache.commons - commons-lang3 - 3.7 - - - - - commons-io - commons-io - 2.5 - - - commons-fileupload - commons-fileupload - 1.3.2 - - - - - com.alibaba - fastjson - 1.2.41 - - - - com.fasterxml.jackson.core - jackson-core - - - com.fasterxml.jackson.core - jackson-databind - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - - - com.fasterxml.jackson.module - jackson-module-parameter-names - - - - - io.springfox - springfox-swagger2 - 2.7.0 - - - - - - io.springfox - springfox-swagger-ui - 2.7.0 - - - - org.springframework - spring-context-support - - - - - - org.quartz-scheduler - quartz - 2.3.0 - - - - - - - org.apache.shiro - shiro-quartz - 1.2.3 - - - - org.opensymphony.quartz - quartz - - - - - - - - - - - - - com.len - len-core - 1.0-SNAPSHOT - - - - com.len - len-web - 1.0-SNAPSHOT - - - com.len - len-sys - 1.0-SNAPSHOT - - - com.len - len-activiti - 1.0-SNAPSHOT - - - - - - lenosp - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.4.2 - - true - - - - - + + + 4.0.0 + + com.len + lenosp + pom + 1.0-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 1.5.9.RELEASE + + + + UTF-8 + 1.8 + + + + len-core + len-sys + len-web + len-activiti + + + + + + org.springframework.boot + spring-boot-starter-test + + + junit + junit + 4.12 + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.1 + + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-starter-freemarker + + + + + + + mysql + mysql-connector-java + 5.1.6 + + + + + com.alibaba + druid + 1.0.24 + + + + + org.mybatis + mybatis-spring + 1.3.0 + + + + + com.github.pagehelper + pagehelper + 5.1.2 + + + com.github.pagehelper + pagehelper-spring-boot-autoconfigure + 1.2.3 + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.3 + + + + org.mybatis + mybatis + 3.4.1 + + + + + ehcache-core + net.sf.ehcache + 2.5.0 + + + org.apache.shiro + shiro-ehcache + 1.2.2 + + + + + org.apache.shiro + shiro-aspectj + 1.4.0 + + + + + + org.slf4j + slf4j-api + 1.7.25 + + + + + org.apache.shiro + shiro-core + 1.2.3 + + + + + org.projectlombok + lombok + 1.16.10 + provided + + + + org.apache.shiro + shiro-web + 1.2.3 + + + org.apache.shiro + shiro-spring + 1.2.3 + + + + net.mingsoft + shiro-freemarker-tags + 0.1 + + + + + org.apache.commons + commons-lang3 + 3.7 + + + + + commons-io + commons-io + 2.5 + + + commons-fileupload + commons-fileupload + 1.3.2 + + + + + com.alibaba + fastjson + 1.2.41 + + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + + + com.fasterxml.jackson.module + jackson-module-parameter-names + + + + + io.springfox + springfox-swagger2 + 2.7.0 + + + + + + io.springfox + springfox-swagger-ui + 2.7.0 + + + + org.springframework + spring-context-support + + + + + + org.quartz-scheduler + quartz + 2.3.0 + + + cn.hutool + hutool-core + 4.0.10 + + + + + + + + org.apache.shiro + shiro-quartz + 1.2.3 + + + + org.opensymphony.quartz + quartz + + + + + + + + + + + + + com.len + len-core + 1.0-SNAPSHOT + + + + com.len + len-web + 1.0-SNAPSHOT + + + com.len + len-sys + 1.0-SNAPSHOT + + + com.len + len-activiti + 1.0-SNAPSHOT + + + + + + lenosp + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.4.2 + + true + + + + + \ No newline at end of file