@Test public void testPersistParser() { SAXReader reader = new SAXReader(); URL url = this.getClass().getResource("/persist_definition.xml"); Document document = null; try { document = reader.read(url); } catch (DocumentException e) { e.printStackTrace(); } String definitionContent = document.asXML(); DefinitionHelper.getInstance().deployDefinition("persist_definition", "测试", definitionContent, true); DefinitionHelper.getInstance().deployDefinition("persist_definition", "测试", definitionContent, true); Definition definition = persistParser.parse("persist_definition", 0); Assert.assertEquals("persist_definition", definition.getName()); Assert.assertEquals(2, definition.getVersion()); Assert.assertNotNull(definition.getState("i'm start")); Definition definition1 = persistParser.parse("persist_definition", 1); Assert.assertEquals(1, definition1.getVersion()); }
@Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()) .andStatusEqualTo(true); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } else { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName).andDefinitionVersionEqualTo( processVersion).andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } require(definitionDO != null, String.format("definition [%s:%s ] not found in DB", processName, processVersion)); Document processXML; try { processXML = DocumentHelper.parseText(definitionDO.getContent()); } catch (DocumentException e) { logger.error("parse definition content error:" + e.getMessage(), e); logger.error("error content:\n" + definitionDO.getContent()); throw new IllegalArgumentException("parse definition content error", e); } return super.parser0(processName, definitionDO.getDefinitionVersion(), processXML, definitionDO.getStatus()); }
PersistParser extends Parser { @Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()) .andStatusEqualTo(true); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } else { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName).andDefinitionVersionEqualTo( processVersion).andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } require(definitionDO != null, String.format("definition [%s:%s ] not found in DB", processName, processVersion)); Document processXML; try { processXML = DocumentHelper.parseText(definitionDO.getContent()); } catch (DocumentException e) { logger.error("parse definition content error:" + e.getMessage(), e); logger.error("error content:\n" + definitionDO.getContent()); throw new IllegalArgumentException("parse definition content error", e); } return super.parser0(processName, definitionDO.getDefinitionVersion(), processXML, definitionDO.getStatus()); } }
PersistParser extends Parser { @Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()) .andStatusEqualTo(true); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } else { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName).andDefinitionVersionEqualTo( processVersion).andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } require(definitionDO != null, String.format("definition [%s:%s ] not found in DB", processName, processVersion)); Document processXML; try { processXML = DocumentHelper.parseText(definitionDO.getContent()); } catch (DocumentException e) { logger.error("parse definition content error:" + e.getMessage(), e); logger.error("error content:\n" + definitionDO.getContent()); throw new IllegalArgumentException("parse definition content error", e); } return super.parser0(processName, definitionDO.getDefinitionVersion(), processXML, definitionDO.getStatus()); }  }
PersistParser extends Parser { @Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()) .andStatusEqualTo(true); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } else { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName).andDefinitionVersionEqualTo( processVersion).andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } require(definitionDO != null, String.format("definition [%s:%s ] not found in DB", processName, processVersion)); Document processXML; try { processXML = DocumentHelper.parseText(definitionDO.getContent()); } catch (DocumentException e) { logger.error("parse definition content error:" + e.getMessage(), e); logger.error("error content:\n" + definitionDO.getContent()); throw new IllegalArgumentException("parse definition content error", e); } return super.parser0(processName, definitionDO.getDefinitionVersion(), processXML, definitionDO.getStatus()); }  @Override boolean needRefresh(String processName, int processVersion, Definition oldDefinition); @Override Definition parse(String processName, int processVersion); }
PersistParser extends Parser { @Override public Definition parse(String processName, int processVersion) { DefinitionDO definitionDO; if (processVersion == 0) { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName) .andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()) .andStatusEqualTo(true); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } else { DefinitionDOExample definitionDOExample = new DefinitionDOExample(); definitionDOExample.createCriteria().andDefinitionNameEqualTo(processName).andDefinitionVersionEqualTo( processVersion).andOwnSignEqualTo(CoreModule.getInstance().getOwnSign()); List<DefinitionDO> definitionDOList = definitionDOMapper.selectByExampleWithBLOBs(definitionDOExample); definitionDO = definitionDOList != null && !definitionDOList.isEmpty() ? definitionDOList.get(0) : null; } require(definitionDO != null, String.format("definition [%s:%s ] not found in DB", processName, processVersion)); Document processXML; try { processXML = DocumentHelper.parseText(definitionDO.getContent()); } catch (DocumentException e) { logger.error("parse definition content error:" + e.getMessage(), e); logger.error("error content:\n" + definitionDO.getContent()); throw new IllegalArgumentException("parse definition content error", e); } return super.parser0(processName, definitionDO.getDefinitionVersion(), processXML, definitionDO.getStatus()); }  @Override boolean needRefresh(String processName, int processVersion, Definition oldDefinition); @Override Definition parse(String processName, int processVersion);  }