Examples of ResourceEntity


Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

  }

  public Void execute(CommandContext commandContext) {
    // TODO Auto-generated method stub

    ResourceEntity resourceEntity = new ResourceEntity();
    resourceEntity.setId(resourceId);
    resourceEntity
        .setBytes(IoUtil.readInputStream(inputStream, resourceId));

    commandContext.getResourceManager().updateResource(resourceEntity);
    return null;
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

    Map<String, ResourceEntity> resources = deployment.getResources();

    //if (resources.keySet().size() != 2) {
    //  throw new FixFlowException("发布的流程资源文件必须含有.bpmn和.png文件");
    //}
    ResourceEntity resourceBpmn = null;
    ResourceEntity resourcePng = null;

    for (String resourceName : resources.keySet()) {
      LOG.info("资源 " + resourceName + " 发布!");
      if (resourceName.toLowerCase().endsWith(BPMN_RESOURCE_SUFFIX)) {
        resourceBpmn = resources.get(resourceName);
      } else {
        if (resourceName.toLowerCase().endsWith(DIAGRAM_SUFFIXES)) {
          resourcePng = resources.get(resourceName);
        }
      }
    }

    if (resourceBpmn == null) {
      throw new FixFlowException("发布的流程资源文件必须含有.bpmn");
    }

    byte[] bytes = resourceBpmn.getBytes();
    ResourceSet resourceSet = getResourceSet();
    String tmp = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getDefaultTemplatePath();
    String filePath = this.getClass().getClassLoader().getResource(tmp).toString();
    Resource ddddResource = null;
    if (!filePath.startsWith("jar")) {
      try {
        filePath = java.net.URLDecoder.decode(ReflectUtil.getResource(tmp).getFile(), "utf-8");
      } catch (UnsupportedEncodingException e) {
        // TODO 自动生成的 catch 块
        e.printStackTrace();
        throw new FixFlowException("流程定义文件加载失败!", e);
      }
      ddddResource = resourceSet.createResource(URI.createFileURI(filePath));
    } else {
      ddddResource = resourceSet.createResource(URI.createURI(filePath));
    }

    try {
      ddddResource.load(new ByteArrayInputStream(bytes), null);
    } catch (UnsupportedEncodingException e) {
      // TODO Auto-generated catch block
      throw new FixFlowException("定义文件加载失败!", e);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      throw new FixFlowException("定义文件加载失败!", e);
    }

    DefinitionsBehavior definitions = (DefinitionsBehavior) ddddResource.getContents().get(0).eContents().get(0);

    ProcessDefinitionBehavior process = null;
    for (RootElement rootElement : definitions.getRootElements()) {
      if (rootElement instanceof ProcessDefinitionBehavior) {

        // ProcessDefinitionBehavior
        // processObj=(ProcessDefinitionBehavior)rootElement;
        // if(processObj.getProcessDefinitionKey().equals("")){
        process = (ProcessDefinitionBehavior) rootElement;
        break;
        // }

      }
    }
    //增加模型验证,by ych 2013 12 27
    if(process.isVerification()){
      @SuppressWarnings("unused")
      StringBuffer sb = new StringBuffer();
      String result = VerificationUtil.verifyAll(process);
      if(result.length() > 0){
        throw new FixFlowException(result);
      }
    }
    process.setDefinitions(definitions);

    process.setResourceName(resourceBpmn.getName());
    process.setResourceId(resourceBpmn.getId());
    if(resourcePng!=null){
      String diagramResourceName = StringUtil.getString(resourcePng.getName());
      process.setDiagramResourceName(diagramResourceName);
    }
   

    CommandContext commandContext = Context.getCommandContext();
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

   
    return resourceSet;
  }

  protected void createResource(String name, byte[] bytes, DeploymentEntity deploymentEntity) {
    ResourceEntity resource = new ResourceEntity();
    resource.setName(name);
    resource.setBytes(bytes);
    resource.setDeploymentId(deploymentEntity.getId());

    Context.getCommandContext().getDbSqlSession().insert("insertResource", resource);
  }
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

      }
     
 
     
     
      ResourceEntity resourceEntityNewBpmn = null;
      ResourceEntity resourceEntityNewPng = null;
     
     
      for ( ResourceEntity resourceEntityNew : deployment.getResources().values()) {
        if (resourceEntityNew.getName().toLowerCase().endsWith(BpmnDeployer.BPMN_RESOURCE_SUFFIX)) {
          resourceEntityNewBpmn = resourceEntityNew;
        } else {
          if (resourceEntityNew.getName().toLowerCase().endsWith(BpmnDeployer.DIAGRAM_SUFFIXES)) {
            resourceEntityNewPng = resourceEntityNew;
          }
        }
      }
     
     
      for ( ResourceEntity resourceEntityOld : deploymentOld.getResources().values()) {
        if (resourceEntityOld.getName().toLowerCase().endsWith(BpmnDeployer.BPMN_RESOURCE_SUFFIX)) {
          resourceEntityOld.setBytes(resourceEntityNewBpmn.getBytes());
        } else {
          if (resourceEntityOld.getName().toLowerCase().endsWith(BpmnDeployer.DIAGRAM_SUFFIXES)) {
            resourceEntityOld.setBytes(resourceEntityNewPng.getBytes());
          }
        }
      }
     
      deploymentOld.setUpdateDeploymentId(deployment.getUpdateDeploymentId());
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

    Map<String, ResourceEntity> savedResources = saved.getResources();
    if (!resources.keySet().equals(savedResources.keySet())) {
      return true;
    }
    for (String resourceName : resources.keySet()) {
      ResourceEntity resource = resources.get(resourceName);
      byte[] bytes = resource.getBytes();
      ResourceEntity savedResource = savedResources.get(resourceName);
      byte[] savedBytes = savedResource.getBytes();
      if (!Arrays.equals(bytes, savedBytes)) {
        return true;
      }
    }
    return false;
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

      }
    }
   
    String deploymentId=processDefinitionBehavior.getDeploymentId();
    String diagramResourceName=processDefinitionBehavior.getDiagramResourceName();
    ResourceEntity resourceEntity=commandContext.getResourceManager().findResourceByDeploymentIdAndResourceName(deploymentId, diagramResourceName);
    InputStream inputStream = new ByteArrayInputStream(resourceEntity.getBytes());
    return inputStream;
   
 
  }
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

      processEngine = getProcessEngine(userid);
      DeploymentEntity deploymentEntity= processEngine.getModelService().getDeploymentEntity(deploymentId);
      Map<String,ResourceEntity> map = deploymentEntity.getResources();
      for(String key :map.keySet()){
        Map<String,Object> resultMap = new HashMap<String,Object>();
        ResourceEntity resourceEntity = map.get(key);
        resultMap.put("FILENAME", resourceEntity.getName());
        resultMap.put("BYTES", resourceEntity.getBytes());
        resultList.add(resultMap);
      }
     
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

  public DeploymentBuilder addInputStream(String resourceName, InputStream inputStream) {
    if (inputStream == null) {
      throw new FixFlowException("inputStream for resource '" + resourceName + "' is null");
    }
    byte[] bytes = IoUtil.readInputStream(inputStream, resourceName);
    ResourceEntity resource = new ResourceEntity();
    resource.setName(resourceName);
    resource.setBytes(bytes);
    deployment.addResource(resource);
    return this;
  }
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

  public DeploymentBuilder addString(String resourceName, String text) {
    if (text == null) {
      throw new FixFlowException("text is null");
    }
    ResourceEntity resource = new ResourceEntity();
    resource.setName(resourceName);
    resource.setBytes(text.getBytes());
    deployment.addResource(resource);
    return this;
  }
View Full Code Here

Examples of com.founder.fix.fixflow.core.impl.persistence.definition.ResourceEntity

      ZipEntry entry = zipInputStream.getNextEntry();
      while (entry != null) {
        if (!entry.isDirectory()) {
          String entryName = entry.getName();
          byte[] bytes = IoUtil.readInputStream(zipInputStream, entryName);
          ResourceEntity resource = new ResourceEntity();
          resource.setName(entryName);
          resource.setBytes(bytes);
          deployment.addResource(resource);
        }
        entry = zipInputStream.getNextEntry();
      }
    } catch (Exception e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.