@Override public boolean equals(Object obj) { if (!(obj instanceof RuleBaseElement)) { return false; } RuleBaseElement other = (RuleBaseElement) obj; return (code == null || code.equals(other.code)) && (type == null || type.equals(other.type)) && (packageName == null || packageName.equals(other.packageName)) && (name == null || name.equals(other.name)); }
return false; } else if (!this.type.equals(other.type)) { return false;
private void installRuleBaseElement(File artifact) throws RuleBaseException, IOException, SAXException, ParserConfigurationException { RuleBaseElementId id = getIdforFile(artifact); String code = FileUtils.readFileToString(artifact); ruleManager.addOrUpdate(id, code); if (id.getType().equals(RuleBaseElementType.Process)) { cache.put(artifact.getName(), id); } LOGGER.info("Successfully installed workflow file \"{}\"", artifact.getName()); }
private RuleBaseElementId getIdforFile(File artifact) throws RuleBaseException, SAXException, IOException, ParserConfigurationException { RuleBaseElementType type = getTypeFromFile(artifact); String name = FilenameUtils.removeExtension(artifact.getName()); RuleBaseElementId id = new RuleBaseElementId(type, name); if (artifact.exists() && type.equals(RuleBaseElementType.Process)) { id.setPackageName(readPackageNameFromProcessFile(artifact)); } return id; }
@Override public void update(File artifact) throws Exception { LOGGER.debug("WorkflowDeployer.update(\"{}\")", artifact.getAbsolutePath()); try { RuleBaseElementId id = getIdforFile(artifact); String code = FileUtils.readFileToString(artifact); boolean changed = false; if (id.getType().equals(RuleBaseElementType.Process)) { RuleBaseElementId cachedId = cache.get(artifact.getName()); if (!id.equals(cachedId)) { ruleManager.delete(cachedId); changed = true; } } ruleManager.addOrUpdate(id, code); if (changed) { cache.put(artifact.getName(), id); } } catch (Exception e) { LOGGER.error(e.getMessage()); throw e; } LOGGER.info("Successfully updated workflow file \"{}\"", artifact.getName()); }
private void doUninstall(File artifact) throws Exception { RuleBaseElementType type = getTypeFromFile(artifact); if (type != null) { RuleBaseElementId id = getIdforFile(artifact); if (id.getType().equals(RuleBaseElementType.Process)) { id = cache.remove(artifact.getName()); } ruleManager.delete(id); return; } String extension = FilenameUtils.getExtension(artifact.getName()); if (IMPORT_ENDING.equals(extension)) { unInstallImportFile(artifact); } else if (GLOBAL_ENDING.equals(extension)) { unInstallGlobalFile(artifact); } }