added DecisionTable support
This commit is contained in:
parent
04d26fb251
commit
ee0f0b4824
24
pom.xml
24
pom.xml
@ -42,26 +42,26 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<maven.version>3.6.3</maven.version>
|
<maven.version>3.9.9</maven.version>
|
||||||
|
|
||||||
<jersey.version>2.39.1</jersey.version>
|
<jersey.version>2.46</jersey.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>aps-public-rest-api</artifactId>
|
<artifactId>aps-public-rest-api</artifactId>
|
||||||
<version>2.0.17</version>
|
<version>3.0.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.inteligr8.alfresco</groupId>
|
<groupId>com.inteligr8.alfresco</groupId>
|
||||||
<artifactId>aps-public-rest-client</artifactId>
|
<artifactId>aps-public-rest-client</artifactId>
|
||||||
<version>2.0.5-jersey</version>
|
<version>3.0.2-jersey</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.17.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.inject</groupId>
|
<groupId>org.glassfish.jersey.inject</groupId>
|
||||||
@ -76,7 +76,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.shared</groupId>
|
<groupId>org.apache.maven.shared</groupId>
|
||||||
<artifactId>file-management</artifactId>
|
<artifactId>file-management</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||||
<artifactId>maven-plugin-annotations</artifactId>
|
<artifactId>maven-plugin-annotations</artifactId>
|
||||||
<version>3.6.0</version>
|
<version>3.15.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -111,7 +111,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.13.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -121,7 +121,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-invoker-plugin</artifactId>
|
<artifactId>maven-invoker-plugin</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.9.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<projectsDirectory>${basedir}/src/it</projectsDirectory>
|
<projectsDirectory>${basedir}/src/it</projectsDirectory>
|
||||||
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
|
||||||
@ -146,7 +146,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-plugin-plugin</artifactId>
|
<artifactId>maven-plugin-plugin</artifactId>
|
||||||
<version>3.6.1</version>
|
<version>3.15.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<goalPrefix>aps-model</goalPrefix>
|
<goalPrefix>aps-model</goalPrefix>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -168,7 +168,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-component-metadata</artifactId>
|
<artifactId>plexus-component-metadata</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.2.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -269,7 +269,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.sonatype.plugins</groupId>
|
<groupId>org.sonatype.plugins</groupId>
|
||||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||||
<version>1.6.13</version>
|
<version>1.7.0</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<serverId>ossrh</serverId>
|
<serverId>ossrh</serverId>
|
||||||
|
@ -45,4 +45,9 @@ public interface ApsAppCrawlable {
|
|||||||
*/
|
*/
|
||||||
ApsFileTransformer getFormJsonTransformer();
|
ApsFileTransformer getFormJsonTransformer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return A file transformer for APS Decision Table JSON files.
|
||||||
|
*/
|
||||||
|
ApsFileTransformer getDecisionTableJsonTransformer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ public class ApsAppCrawler {
|
|||||||
|
|
||||||
this.transform(crawlable.getAppJsonTransformer(), this.appDescriptor, this.appName, null);
|
this.transform(crawlable.getAppJsonTransformer(), this.appDescriptor, this.appName, null);
|
||||||
this.crawlModels("form-models", crawlable.getFormJsonTransformer());
|
this.crawlModels("form-models", crawlable.getFormJsonTransformer());
|
||||||
|
this.crawlModels("decision-table-models", crawlable.getDecisionTableJsonTransformer());
|
||||||
this.crawlModels("bpmn-models", processTransformers);
|
this.crawlModels("bpmn-models", processTransformers);
|
||||||
this.crawlModels("bpmn-subprocess-models", crawlable.getProcessJsonTransformer());
|
this.crawlModels("bpmn-subprocess-models", crawlable.getProcessJsonTransformer());
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import org.apache.maven.settings.crypto.SettingsDecrypter;
|
|||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ApsClientJerseyConfiguration;
|
import com.inteligr8.alfresco.activiti.ApsClientJerseyConfiguration;
|
||||||
import com.inteligr8.alfresco.activiti.ApsClientJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsClientJerseyImpl;
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsProtectedRestApiJerseyImpl;
|
||||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public abstract class ApsAddressibleGoal extends DisablableGoal {
|
|||||||
@Component
|
@Component
|
||||||
private SettingsDecrypter decrypter;
|
private SettingsDecrypter decrypter;
|
||||||
|
|
||||||
private ApsPublicRestApiJerseyImpl api;
|
private ApsProtectedRestApiJerseyImpl api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an APS client configuration.
|
* Retrieves an APS client configuration.
|
||||||
@ -146,11 +146,11 @@ public abstract class ApsAddressibleGoal extends DisablableGoal {
|
|||||||
* @return An APS API instance.
|
* @return An APS API instance.
|
||||||
* @throws MojoExecutionException The APS API failed to initialize.
|
* @throws MojoExecutionException The APS API failed to initialize.
|
||||||
*/
|
*/
|
||||||
public synchronized ApsPublicRestApiJerseyImpl getApsApi() throws MojoExecutionException {
|
public synchronized ApsProtectedRestApiJerseyImpl getApsApi() throws MojoExecutionException {
|
||||||
if (this.api == null) {
|
if (this.api == null) {
|
||||||
ApsClientJerseyConfiguration config = this.getApsClientConfiguration();
|
ApsClientJerseyConfiguration config = this.getApsClientConfiguration();
|
||||||
ApsClientJerseyImpl apsClient = new ApsClientJerseyImpl(config);
|
ApsClientJerseyImpl apsClient = new ApsClientJerseyImpl(config);
|
||||||
this.api = new ApsPublicRestApiJerseyImpl(apsClient);
|
this.api = new ApsProtectedRestApiJerseyImpl(apsClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.api;
|
return this.api;
|
||||||
|
@ -21,7 +21,7 @@ import org.apache.maven.plugin.MojoExecutionException;
|
|||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
|
|
||||||
import com.inteligr8.activiti.model.ResultList;
|
import com.inteligr8.activiti.model.ResultList;
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
||||||
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
|
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
|
||||||
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public abstract class ApsAppAddressibleGoal extends ApsAddressibleGoal {
|
|||||||
* @throws MojoExecutionException The APS API failed to initialize.
|
* @throws MojoExecutionException The APS API failed to initialize.
|
||||||
*/
|
*/
|
||||||
protected Map<String, ModelRepresentation> buildAppNameMap() throws MojoExecutionException {
|
protected Map<String, ModelRepresentation> buildAppNameMap() throws MojoExecutionException {
|
||||||
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
ApsPublicRestApi api = this.getApsApi();
|
||||||
|
|
||||||
Map<String, ModelRepresentation> apps = new HashMap<>(16);
|
Map<String, ModelRepresentation> apps = new HashMap<>(16);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import org.apache.maven.plugins.annotations.Mojo;
|
|||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that implements an APS service download goal.
|
* A class that implements an APS service download goal.
|
||||||
@ -70,7 +70,7 @@ public class DownloadAppGoal extends ApsAppAddressibleGoal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private File downloadApp(long appId) throws MojoExecutionException {
|
private File downloadApp(long appId) throws MojoExecutionException {
|
||||||
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
ApsPublicRestApi api = this.getApsApi();
|
||||||
this.getLog().debug("Downloading APS App: " + appId);
|
this.getLog().debug("Downloading APS App: " + appId);
|
||||||
return api.getAppDefinitionsApi().export(appId);
|
return api.getAppDefinitionsApi().export(appId);
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,6 @@ import java.io.InputStream;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
@ -35,6 +33,8 @@ import com.inteligr8.alfresco.activiti.model.EmailTemplate;
|
|||||||
import com.inteligr8.maven.aps.modeling.normalizer.ApsTemplateJsonNormalizer;
|
import com.inteligr8.maven.aps.modeling.normalizer.ApsTemplateJsonNormalizer;
|
||||||
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
|
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that implements an APS service download goal.
|
* A class that implements an APS service download goal.
|
||||||
*
|
*
|
||||||
|
@ -16,19 +16,19 @@ package com.inteligr8.maven.aps.modeling.goal;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
||||||
import com.inteligr8.alfresco.activiti.model.AppDefinitionPublishRepresentation;
|
import com.inteligr8.alfresco.activiti.model.AppDefinitionPublishRepresentation;
|
||||||
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that implements an APS Service publish goal.
|
* A class that implements an APS Service publish goal.
|
||||||
*
|
*
|
||||||
@ -59,7 +59,7 @@ public class PublishAppGoal extends ApsAppAddressibleGoal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void publishApp(Long appId) throws IOException, MojoExecutionException {
|
private void publishApp(Long appId) throws IOException, MojoExecutionException {
|
||||||
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
ApsPublicRestApi api = this.getApsApi();
|
||||||
|
|
||||||
AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
|
AppDefinitionPublishRepresentation appDefPublish = new AppDefinitionPublishRepresentation();
|
||||||
appDefPublish.setComment(this.comment);
|
appDefPublish.setComment(this.comment);
|
||||||
|
@ -20,20 +20,20 @@ import java.io.FileInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugins.annotations.Mojo;
|
import org.apache.maven.plugins.annotations.Mojo;
|
||||||
import org.apache.maven.plugins.annotations.Parameter;
|
import org.apache.maven.plugins.annotations.Parameter;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApiJerseyImpl;
|
import com.inteligr8.alfresco.activiti.ApsPublicRestJerseyApi;
|
||||||
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
import com.inteligr8.alfresco.activiti.model.AppDefinitionUpdateResultRepresentation;
|
||||||
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
|
import com.inteligr8.alfresco.activiti.model.FileMultipartJersey;
|
||||||
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
||||||
|
|
||||||
|
import jakarta.ws.rs.WebApplicationException;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that implements an APS service upload goal.
|
* A class that implements an APS service upload goal.
|
||||||
*
|
*
|
||||||
@ -91,7 +91,7 @@ public class UploadAppGoal extends ApsAppAddressibleGoal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void uploadApp(ModelRepresentation appModel, File appZip) throws IOException, MojoExecutionException, MojoFailureException {
|
private void uploadApp(ModelRepresentation appModel, File appZip) throws IOException, MojoExecutionException, MojoFailureException {
|
||||||
ApsPublicRestApiJerseyImpl api = this.getApsApi();
|
ApsPublicRestJerseyApi api = this.getApsApi();
|
||||||
|
|
||||||
FileInputStream fistream = new FileInputStream(appZip);
|
FileInputStream fistream = new FileInputStream(appZip);
|
||||||
BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize);
|
BufferedInputStream bistream = new BufferedInputStream(fistream, this.bufferSize);
|
||||||
|
@ -62,6 +62,11 @@ public class ApsAppNormalizer implements ApsAppCrawlable {
|
|||||||
public ApsFileTransformer getFormJsonTransformer() {
|
public ApsFileTransformer getFormJsonTransformer() {
|
||||||
return new ApsFormJsonNormalizer();
|
return new ApsFormJsonNormalizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApsFileTransformer getDecisionTableJsonTransformer() {
|
||||||
|
return new ApsDecisionTableJsonNormalizer();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApsFileTransformer getProcessJsonTransformer() {
|
public ApsFileTransformer getProcessJsonTransformer() {
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.inteligr8.maven.aps.modeling.normalizer;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements an APS Decision Table JSON configuration file
|
||||||
|
* normalizer.
|
||||||
|
*
|
||||||
|
* This does nothing but log at this time.
|
||||||
|
*
|
||||||
|
* @author brian@inteligr8.com
|
||||||
|
*/
|
||||||
|
public class ApsDecisionTableJsonNormalizer implements ApsFileNormalizer {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(ApsDecisionTableJsonNormalizer.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void normalizeFile(File file, String modelName) throws IOException {
|
||||||
|
this.logger.debug("Normalizing Form JSON file: {}", file);
|
||||||
|
this.logger.trace("Nothing to normalize: {}", modelName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -26,13 +26,11 @@ import java.util.regex.Pattern;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.inteligr8.activiti.model.Datum;
|
|
||||||
import com.inteligr8.activiti.model.ResultList;
|
import com.inteligr8.activiti.model.ResultList;
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
||||||
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
|
import com.inteligr8.alfresco.activiti.api.ModelsApi.ModelType;
|
||||||
import com.inteligr8.alfresco.activiti.model.GroupLight;
|
import com.inteligr8.alfresco.activiti.model.GroupLight;
|
||||||
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
import com.inteligr8.alfresco.activiti.model.ModelRepresentation;
|
||||||
import com.inteligr8.alfresco.activiti.model.ResultListDataRepresentation;
|
|
||||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||||
import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawlable;
|
import com.inteligr8.maven.aps.modeling.crawler.ApsAppCrawlable;
|
||||||
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
|
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
|
||||||
@ -66,6 +64,7 @@ public class ApsAppTranslator implements ApsAppCrawlable {
|
|||||||
private boolean indexesBuilt = false;
|
private boolean indexesBuilt = false;
|
||||||
private Map<String, GroupLight> apsOrgIndex;
|
private Map<String, GroupLight> apsOrgIndex;
|
||||||
private Index<Long, String> apsFormIndex;
|
private Index<Long, String> apsFormIndex;
|
||||||
|
private Index<Long, String> apsDecisionTableIndex;
|
||||||
private Index<Long, String> apsProcessIndex;
|
private Index<Long, String> apsProcessIndex;
|
||||||
private Index<Long, String> fileFormIndex;
|
private Index<Long, String> fileFormIndex;
|
||||||
private Index<Long, String> fileProcessIndex;
|
private Index<Long, String> fileProcessIndex;
|
||||||
@ -109,6 +108,9 @@ public class ApsAppTranslator implements ApsAppCrawlable {
|
|||||||
|
|
||||||
this.apsFormIndex = this.buildApsModelIndex(ModelType.Form);
|
this.apsFormIndex = this.buildApsModelIndex(ModelType.Form);
|
||||||
this.logLarge("APS form models: {}", this.apsFormIndex);
|
this.logLarge("APS form models: {}", this.apsFormIndex);
|
||||||
|
|
||||||
|
this.apsDecisionTableIndex = this.buildApsModelIndex(ModelType.DecisionTable);
|
||||||
|
this.logLarge("APS decision table models: {}", this.apsDecisionTableIndex);
|
||||||
|
|
||||||
this.fileFormIndex = this.buildFileIndex("form-models", this.apsFormIndex, true);
|
this.fileFormIndex = this.buildFileIndex("form-models", this.apsFormIndex, true);
|
||||||
this.logLarge("File form models: {}", this.fileFormIndex);
|
this.logLarge("File form models: {}", this.fileFormIndex);
|
||||||
@ -158,6 +160,15 @@ public class ApsAppTranslator implements ApsAppCrawlable {
|
|||||||
return new ApsFormJsonTranslator(
|
return new ApsFormJsonTranslator(
|
||||||
this.apsFormIndex);
|
this.apsFormIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApsFileTransformer getDecisionTableJsonTransformer() {
|
||||||
|
if (!this.indexesBuilt)
|
||||||
|
throw new IllegalStateException("The indexes are never built");
|
||||||
|
|
||||||
|
return new ApsDecisionTableJsonTranslator(
|
||||||
|
this.apsDecisionTableIndex);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApsFileTransformer getProcessJsonTransformer() {
|
public ApsFileTransformer getProcessJsonTransformer() {
|
||||||
@ -168,7 +179,8 @@ public class ApsAppTranslator implements ApsAppCrawlable {
|
|||||||
this.api,
|
this.api,
|
||||||
this.apsProcessIndex,
|
this.apsProcessIndex,
|
||||||
this.apsOrgIndex,
|
this.apsOrgIndex,
|
||||||
this.apsFormIndex);
|
this.apsFormIndex,
|
||||||
|
this.apsDecisionTableIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -181,6 +193,7 @@ public class ApsAppTranslator implements ApsAppCrawlable {
|
|||||||
this.apsProcessIndex,
|
this.apsProcessIndex,
|
||||||
this.apsOrgIndex,
|
this.apsOrgIndex,
|
||||||
this.apsFormIndex,
|
this.apsFormIndex,
|
||||||
|
this.apsDecisionTableIndex,
|
||||||
this.fileFormIndex);
|
this.fileFormIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.inteligr8.maven.aps.modeling.translator;
|
||||||
|
|
||||||
|
import com.inteligr8.maven.aps.modeling.util.Index;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements an APS Decision Table JSON configuration file
|
||||||
|
* translator.
|
||||||
|
*
|
||||||
|
* This will translate the decision table ID embedded into APS Decision Table
|
||||||
|
* descriptor.
|
||||||
|
*
|
||||||
|
* @author brian@inteligr8.com
|
||||||
|
*/
|
||||||
|
public class ApsDecisionTableJsonTranslator extends ApsResourceJsonTranslator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor initializes the default translator.
|
||||||
|
*
|
||||||
|
* @param apsDecisionTableIndex A map of form IDs to form names as defined in the APS Service.
|
||||||
|
*/
|
||||||
|
public ApsDecisionTableJsonTranslator(Index<Long, String> apsDecisionTableIndex) {
|
||||||
|
super(apsDecisionTableIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,16 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.inteligr8.maven.aps.modeling.translator;
|
package com.inteligr8.maven.aps.modeling.translator;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import com.inteligr8.maven.aps.modeling.util.Index;
|
import com.inteligr8.maven.aps.modeling.util.Index;
|
||||||
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class implements an APS Form JSON configuration file translator.
|
* This class implements an APS Form JSON configuration file translator.
|
||||||
@ -32,10 +23,7 @@ import com.inteligr8.maven.aps.modeling.util.ModelUtil;
|
|||||||
*
|
*
|
||||||
* @author brian@inteligr8.com
|
* @author brian@inteligr8.com
|
||||||
*/
|
*/
|
||||||
public class ApsFormJsonTranslator implements ApsFileTranslator {
|
public class ApsFormJsonTranslator extends ApsResourceJsonTranslator {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ApsFormJsonTranslator.class);
|
|
||||||
private final Index<Long, String> apsIndex;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor initializes the default translator.
|
* This constructor initializes the default translator.
|
||||||
@ -43,36 +31,7 @@ public class ApsFormJsonTranslator implements ApsFileTranslator {
|
|||||||
* @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
|
* @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
|
||||||
*/
|
*/
|
||||||
public ApsFormJsonTranslator(Index<Long, String> apsFormIndex) {
|
public ApsFormJsonTranslator(Index<Long, String> apsFormIndex) {
|
||||||
this.apsIndex = apsFormIndex;
|
super(apsFormIndex);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void translateFile(File file, String formName, Long formId) throws IOException {
|
|
||||||
this.logger.debug("Translating JSON file: {}", file);
|
|
||||||
boolean changed = false;
|
|
||||||
|
|
||||||
ObjectNode jsonDescriptor = ModelUtil.getInstance().readJson(file, ObjectNode.class);
|
|
||||||
JsonNode jsonResourceId = jsonDescriptor.get("resourceId");
|
|
||||||
if (jsonResourceId == null || jsonResourceId.isNull()) {
|
|
||||||
this.logger.debug("The form has no ID to translate");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.logger.trace("Found ID {} in the '{}' APS Form descriptor", jsonResourceId, formName);
|
|
||||||
|
|
||||||
Long apsFormId = this.apsIndex.getFirstKey(formName);
|
|
||||||
if (apsFormId == null) {
|
|
||||||
this.logger.debug("The form '{}' does not exist in APS; leaving unchanged", formName);
|
|
||||||
} else if (!formId.equals(apsFormId)) {
|
|
||||||
this.logger.debug("The form '{}' exists in APS with ID {}; changing descriptor", formName, apsFormId);
|
|
||||||
jsonDescriptor.put("resourceId", apsFormId);
|
|
||||||
changed = true;
|
|
||||||
} else {
|
|
||||||
this.logger.trace("The form '{}' ID does not change; leaving unchanged", formName, apsFormId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed)
|
|
||||||
ModelUtil.getInstance().writeJson(jsonDescriptor, file, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,8 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
|
|||||||
private final Index<Long, String> apsIndex;
|
private final Index<Long, String> apsIndex;
|
||||||
private final Map<String, GroupLight> apsOrgIndex;
|
private final Map<String, GroupLight> apsOrgIndex;
|
||||||
private final Index<Long, String> apsFormIndex;
|
private final Index<Long, String> apsFormIndex;
|
||||||
private final Index<Long, String> fileFormIndex;
|
private final Index<Long, String> apsDecisionTableIndex;
|
||||||
|
private final Index<Long, String> fileFormIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor initializes the default translator.
|
* This constructor initializes the default translator.
|
||||||
@ -79,12 +80,14 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
|
|||||||
Index<Long, String> apsProcessIndex,
|
Index<Long, String> apsProcessIndex,
|
||||||
Map<String, GroupLight> apsOrgIndex,
|
Map<String, GroupLight> apsOrgIndex,
|
||||||
Index<Long, String> apsFormIndex,
|
Index<Long, String> apsFormIndex,
|
||||||
|
Index<Long, String> apsDecisionTableIndex,
|
||||||
Index<Long, String> fileFormIndex) {
|
Index<Long, String> fileFormIndex) {
|
||||||
super(api, apsOrgIndex);
|
super(api, apsOrgIndex);
|
||||||
this.apsIndex = apsProcessIndex;
|
this.apsIndex = apsProcessIndex;
|
||||||
this.apsOrgIndex = apsOrgIndex;
|
this.apsOrgIndex = apsOrgIndex;
|
||||||
this.apsFormIndex = apsFormIndex;
|
this.apsFormIndex = apsFormIndex;
|
||||||
this.fileFormIndex = fileFormIndex;
|
this.apsDecisionTableIndex = apsDecisionTableIndex;
|
||||||
|
this.fileFormIndex = fileFormIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -111,6 +114,12 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
|
|||||||
Element formKeyElement = (Element)formKeyElements.item(n);
|
Element formKeyElement = (Element)formKeyElements.item(n);
|
||||||
changed = this.translateTaskForm(formKeyElement) || changed;
|
changed = this.translateTaskForm(formKeyElement) || changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeList decisionTableRefElements = ModelUtil.getInstance().xpath(definitionsElement, "//modeler:decisiontable-reference");
|
||||||
|
for (int n = 0; n < decisionTableRefElements.getLength(); n++) {
|
||||||
|
Element decisionTableRefElement = (Element)decisionTableRefElements.item(n);
|
||||||
|
changed = this.translateDecisionTableRef(decisionTableRefElement, bpmn) || changed;
|
||||||
|
}
|
||||||
|
|
||||||
NodeList subprocessElements = ModelUtil.getInstance().xpath(definitionsElement, "//tns:subProcess");
|
NodeList subprocessElements = ModelUtil.getInstance().xpath(definitionsElement, "//tns:subProcess");
|
||||||
for (int n = 0; n < subprocessElements.getLength(); n++) {
|
for (int n = 0; n < subprocessElements.getLength(); n++) {
|
||||||
@ -258,6 +267,47 @@ public class ApsProcessBpmnTranslator extends ApsOrganizationHandler implements
|
|||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean translateDecisionTableRef(Element decisionTableRefElement, Document xmldoc) throws XPathExpressionException {
|
||||||
|
String dtRefIdStr = decisionTableRefElement.getAttributeNS(NAMESPACE_ACTIVITI_MODELER, "decisiontablereferenceid");
|
||||||
|
this.logger.trace("Translating decision table: {}", dtRefIdStr);
|
||||||
|
if (dtRefIdStr == null)
|
||||||
|
throw new IllegalStateException("A decision table was detected, but no identifier was found");
|
||||||
|
Long dtRefId = new Long(dtRefIdStr);
|
||||||
|
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
String dtRefName = decisionTableRefElement.getAttributeNS(NAMESPACE_ACTIVITI_MODELER, "decisiontablereferencename");
|
||||||
|
if (dtRefName == null)
|
||||||
|
throw new IllegalStateException("A decision table was detected, but no name was found: " + dtRefId);
|
||||||
|
dtRefName = dtRefName.trim();
|
||||||
|
this.logger.trace("Found '{}' decision table in the APS Process BPMN model", dtRefName);
|
||||||
|
|
||||||
|
Long apsDecisionTableId = this.apsDecisionTableIndex.getFirstKey(dtRefName);
|
||||||
|
if (apsDecisionTableId == null) {
|
||||||
|
this.logger.debug("The decision table '{}' does not exist in APS; leaving unchanged", dtRefName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.trace("Found ID {} for the decision table '{}' in the APS Process BPMN model", apsDecisionTableId, dtRefName);
|
||||||
|
|
||||||
|
String dtRefKey = (String) ModelUtil.getInstance().xpath(
|
||||||
|
decisionTableRefElement.getParentNode(),
|
||||||
|
"activiti:field[@name=\"decisionTableReferenceKey\"]/activiti:string/text()",
|
||||||
|
XPathConstants.STRING);
|
||||||
|
if (dtRefKey == null)
|
||||||
|
throw new IllegalStateException("A decision table was detected, but no key was found: " + dtRefId);
|
||||||
|
|
||||||
|
if (!apsDecisionTableId.equals(dtRefId)) {
|
||||||
|
this.logger.debug("The decision table '{}' exists in APS with ID {}; changing model", dtRefName, apsDecisionTableId);
|
||||||
|
decisionTableRefElement.setAttributeNS(NAMESPACE_ACTIVITI_MODELER, "decisiontablereferenceid", apsDecisionTableId.toString());
|
||||||
|
changed = true;
|
||||||
|
} else {
|
||||||
|
this.logger.trace("The decision table '{}' key does not change; leaving unchanged", dtRefName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean translateSubprocess(Element subprocessElement) throws XPathExpressionException {
|
private boolean translateSubprocess(Element subprocessElement) throws XPathExpressionException {
|
||||||
this.logger.trace("Translating subprocess: {}", subprocessElement.getAttribute("id"));
|
this.logger.trace("Translating subprocess: {}", subprocessElement.getAttribute("id"));
|
||||||
|
@ -48,6 +48,7 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
|
|||||||
private final Index<Long, String> apsIndex;
|
private final Index<Long, String> apsIndex;
|
||||||
private final Map<String, GroupLight> apsOrgIndex;
|
private final Map<String, GroupLight> apsOrgIndex;
|
||||||
private final Index<Long, String> apsFormIndex;
|
private final Index<Long, String> apsFormIndex;
|
||||||
|
private final Index<Long, String> apsDecisionTableIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor initializes the default translator.
|
* This constructor initializes the default translator.
|
||||||
@ -56,16 +57,19 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
|
|||||||
* @param apsProcessIndex A map of process IDs to process names as defined in the APS Service.
|
* @param apsProcessIndex A map of process IDs to process names as defined in the APS Service.
|
||||||
* @param apsOrgIndex A map of organizations (groups) to organization meta-data as defined in the APS Service.
|
* @param apsOrgIndex A map of organizations (groups) to organization meta-data as defined in the APS Service.
|
||||||
* @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
|
* @param apsFormIndex A map of form IDs to form names as defined in the APS Service.
|
||||||
|
* @param apsDecisionTableIndex A map of decision table IDs to decision table names as defined in the APS Service.
|
||||||
*/
|
*/
|
||||||
public ApsProcessJsonTranslator(
|
public ApsProcessJsonTranslator(
|
||||||
ApsPublicRestApi api,
|
ApsPublicRestApi api,
|
||||||
Index<Long, String> apsProcessIndex,
|
Index<Long, String> apsProcessIndex,
|
||||||
Map<String, GroupLight> apsOrgIndex,
|
Map<String, GroupLight> apsOrgIndex,
|
||||||
Index<Long, String> apsFormIndex) {
|
Index<Long, String> apsFormIndex,
|
||||||
|
Index<Long, String> apsDecisionTableIndex) {
|
||||||
super(api, apsOrgIndex);
|
super(api, apsOrgIndex);
|
||||||
this.apsIndex = apsProcessIndex;
|
this.apsIndex = apsProcessIndex;
|
||||||
this.apsOrgIndex = apsOrgIndex;
|
this.apsOrgIndex = apsOrgIndex;
|
||||||
this.apsFormIndex = apsFormIndex;
|
this.apsFormIndex = apsFormIndex;
|
||||||
|
this.apsDecisionTableIndex = apsDecisionTableIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,7 +83,7 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
|
|||||||
|
|
||||||
changed = this.translateResourceId(jsonDescriptor, processName, apsProcessId) || changed;
|
changed = this.translateResourceId(jsonDescriptor, processName, apsProcessId) || changed;
|
||||||
changed = this.translateOrganizations(jsonDescriptor, processName) || changed;
|
changed = this.translateOrganizations(jsonDescriptor, processName) || changed;
|
||||||
changed = this.translateForms(jsonDescriptor, processName) || changed;
|
changed = this.translateResources(jsonDescriptor, processName) || changed;
|
||||||
changed = this.translateSubprocesses(jsonDescriptor, processName) || changed;
|
changed = this.translateSubprocesses(jsonDescriptor, processName) || changed;
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
@ -171,8 +175,8 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean translateForms(ObjectNode jsonDescriptor, String processName) {
|
private boolean translateResources(ObjectNode jsonDescriptor, String processName) {
|
||||||
this.logger.trace("Translating forms in process: {}", processName);
|
this.logger.trace("Translating resources in process: {}", processName);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
for (JsonNode jsonChildShape : this.getChildShapes(jsonDescriptor)) {
|
for (JsonNode jsonChildShape : this.getChildShapes(jsonDescriptor)) {
|
||||||
@ -182,6 +186,9 @@ public class ApsProcessJsonTranslator extends ApsOrganizationHandler implements
|
|||||||
|
|
||||||
JsonNode jsonFormRef = (JsonNode)jsonChildShape.get("properties").get("formreference");
|
JsonNode jsonFormRef = (JsonNode)jsonChildShape.get("properties").get("formreference");
|
||||||
changed = this.translateReference(jsonFormRef, this.apsFormIndex) || changed;
|
changed = this.translateReference(jsonFormRef, this.apsFormIndex) || changed;
|
||||||
|
|
||||||
|
JsonNode jsonDecitionTableRef = (JsonNode)jsonChildShape.get("properties").get("decisiontaskdecisiontablereference");
|
||||||
|
changed = this.translateReference(jsonDecitionTableRef, this.apsDecisionTableIndex) || changed;
|
||||||
} catch (NullPointerException npe) {
|
} catch (NullPointerException npe) {
|
||||||
// suppress; gracefully skip
|
// suppress; gracefully skip
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.inteligr8.maven.aps.modeling.translator;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.inteligr8.maven.aps.modeling.util.Index;
|
||||||
|
import com.inteligr8.maven.aps.modeling.util.ModelUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author brian@inteligr8.com
|
||||||
|
*/
|
||||||
|
public class ApsResourceJsonTranslator implements ApsFileTranslator {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
private final Index<Long, String> apsResourceIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor initializes the default translator.
|
||||||
|
*
|
||||||
|
* @param apsResourceIndex A map of resource IDs to resource names as defined in the APS Service.
|
||||||
|
*/
|
||||||
|
public ApsResourceJsonTranslator(Index<Long, String> apsResourceIndex) {
|
||||||
|
this.apsResourceIndex = apsResourceIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void translateFile(File file, String formName, Long resourceId) throws IOException {
|
||||||
|
this.logger.debug("Translating JSON file: {}", file);
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
ObjectNode jsonDescriptor = ModelUtil.getInstance().readJson(file, ObjectNode.class);
|
||||||
|
JsonNode jsonResourceId = jsonDescriptor.get("resourceId");
|
||||||
|
if (jsonResourceId == null || jsonResourceId.isNull()) {
|
||||||
|
this.logger.debug("The resource has no ID to translate");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.trace("Found ID {} in the '{}' APS resource descriptor", jsonResourceId, formName);
|
||||||
|
|
||||||
|
Long apsResourceId = this.apsResourceIndex.getFirstKey(formName);
|
||||||
|
if (apsResourceId == null) {
|
||||||
|
this.logger.debug("The resource '{}' does not exist in APS; leaving unchanged", formName);
|
||||||
|
} else if (!resourceId.equals(apsResourceId)) {
|
||||||
|
this.logger.debug("The resource '{}' exists in APS with ID {}; changing descriptor", formName, apsResourceId);
|
||||||
|
jsonDescriptor.put("resourceId", apsResourceId);
|
||||||
|
changed = true;
|
||||||
|
} else {
|
||||||
|
this.logger.trace("The resource '{}' ID does not change; leaving unchanged", formName, apsResourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changed)
|
||||||
|
ModelUtil.getInstance().writeJson(jsonDescriptor, file, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,7 +21,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.inteligr8.activiti.model.ResultList;
|
import com.inteligr8.activiti.model.ResultList;
|
||||||
import com.inteligr8.alfresco.activiti.ApsPublicRestApi;
|
import com.inteligr8.alfresco.activiti.ApsProtectedRestApi;
|
||||||
import com.inteligr8.alfresco.activiti.model.BaseTemplateLight;
|
import com.inteligr8.alfresco.activiti.model.BaseTemplateLight;
|
||||||
import com.inteligr8.alfresco.activiti.model.Tenant;
|
import com.inteligr8.alfresco.activiti.model.Tenant;
|
||||||
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
|
import com.inteligr8.maven.aps.modeling.crawler.ApsFileTransformer;
|
||||||
@ -49,13 +49,13 @@ import com.inteligr8.maven.aps.modeling.util.Index;
|
|||||||
public class ApsTemplateTranslator implements ApsTemplateCrawlable {
|
public class ApsTemplateTranslator implements ApsTemplateCrawlable {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ApsTemplateTranslator.class);
|
private final Logger logger = LoggerFactory.getLogger(ApsTemplateTranslator.class);
|
||||||
private final ApsPublicRestApi api;
|
private final ApsProtectedRestApi api;
|
||||||
|
|
||||||
private boolean indexesBuilt = false;
|
private boolean indexesBuilt = false;
|
||||||
private Index<Long, String> apsDocumentTemplateIndex;
|
private Index<Long, String> apsDocumentTemplateIndex;
|
||||||
private Index<Long, String> apsCustomEmailTemplateIndex;
|
private Index<Long, String> apsCustomEmailTemplateIndex;
|
||||||
|
|
||||||
public ApsTemplateTranslator(ApsPublicRestApi api) {
|
public ApsTemplateTranslator(ApsProtectedRestApi api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user