diff --git a/build.gradle b/build.gradle index 8281be8..4a59158 100644 --- a/build.gradle +++ b/build.gradle @@ -1,74 +1,156 @@ -apply plugin: 'java' -apply plugin: 'eclipse' -apply plugin: 'application' -sourceCompatibility = 1.7 -targetCompatibility = 1.7 -mainClassName = 'com.gtnexus.appxpress.PlatformModuleManager' - -/* - * Gets the version name from the latest Git tag - * still needs to be added to .jar - */ -def getVersionName = { -> - def stdout = new ByteArrayOutputStream() - exec { - commandLine 'git', 'describe', '--tags' - standardOutput = stdout - } - return stdout.toString().trim() -} - -allprojects { - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:unchecked" - } - } -} +subprojects { + apply plugin: 'java' + apply plugin: 'eclipse' + group = 'com.gtnexus.pmm' + //version = '1.0' + repositories { + mavenCentral() + } -repositories { - mavenCentral() - flatDir { - dirs 'lib' + dependencies { + testCompile 'junit:junit:4.12' + compile 'com.google.guava:guava:19.0' + compile 'org.apache.poi:poi:3.14' + compile 'org.apache.poi:poi-ooxml:3.14' + compile 'org.reflections:reflections:0.9.11' + compile 'commons-cli:commons-cli:1.4' + //compile name: 'commons-cli-1.3-SNAPSHOT' + //compile name: 'zip4j_1.3.2' + compile 'net.lingala.zip4j:zip4j:1.3.2' + compile 'org.mockito:mockito-all:1.9.5' + //compile name: 'mockito-all-1.9.5' } -} -dependencies { - testCompile 'junit:junit:4.12' - compile 'com.google.guava:guava:19.0' - compile 'org.apache.poi:poi:3.14' - compile 'org.apache.poi:poi-ooxml:3.14' - compile name: 'commons-cli-1.3-SNAPSHOT' - compile name: 'zip4j_1.3.2' - compile name: 'mockito-all-1.9.5' } -jar { - baseName = 'pmmanager' - version = '0.1.0' -} +project(':mapp') { + apply plugin: 'application' + mainClassName = 'com.gtnexus.pmm.app.PlatformModuleManager' + dependencies { + compile project(':mapi') + } + /* + * To run app, pass args to app behind -Dexec.args flag + * eg: gradle run -Dexec.args="build -h" + */ + run { + args System.getProperty("exec.args", "").split() + } -task fatJar(type: Jar) { - manifest { - attributes 'Implementation-Title': 'PlatformModuleManager', - 'Implementation-Version': '1.0.0', - 'Main-Class': 'com.gtnexus.appxpress.PlatformModuleManager' - } - baseName = 'pmm' + '-all' - from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } - with jar -} + task fatJar(type: Jar) { + manifest { + attributes 'Implementation-Title': 'PlatformModuleManager', + 'Implementation-Version': '1.0.0', + 'Main-Class': 'com.gtnexus.pmm.app.PlatformModuleManager' + } + baseName = 'pmm' + '-all' + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } + with jar + } -task wrapper(type: Wrapper) { - gradleVersion = '2.3' } -compileJava.doFirst { - println "" - println "on tag -> " + getVersionName() - println "source compatibility >>" + sourceCompatibility - println "java_home: " + System.getProperty("java.home") - println "" -} \ No newline at end of file +//project(':app') { +// apply plugin: 'java' +// dependencies { +// compile project(':api') +// +// testCompile 'junit:junit:4.12' +// compile 'com.google.guava:guava:19.0' +// compile 'org.apache.poi:poi:3.14' +// compile 'org.apache.poi:poi-ooxml:3.14' +// compile 'org.reflections:reflections:0.9.11' +// compile name: 'commons-cli-1.3-SNAPSHOT' +// compile name: 'zip4j_1.3.2' +// compile name: 'mockito-all-1.9.5' +// } +// +// task fatJar(type: Jar) { +// manifest { +// attributes 'Implementation-Title': 'PlatformModuleManager', +// 'Implementation-Version': '1.0.0', +// 'Main-Class': 'com.gtnexus.pmm.PlatformModuleManager' +// } +// baseName = 'pmm' + '-all' +// from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } +// with jar +// } +// +// artifacts { +// fj fatJar +// } +// +//} +// +//apply plugin: 'java' +//apply plugin: 'eclipse' +//apply plugin: 'application' +// +//sourceCompatibility = 1.7 +//targetCompatibility = 1.7 +// +//mainClassName = 'com.gtnexus.pmm.PlatformModuleManager' +// +///* +// * Gets the version name from the latest Git tag +// * still needs to be added to .jar +// */ +//def getVersionName = { -> +// def stdout = new ByteArrayOutputStream() +// exec { +// commandLine 'git', 'describe', '--tags' +// standardOutput = stdout +// } +// return stdout.toString().trim() +//} +// +//allprojects { +//} +// +//repositories { +// mavenCentral() +// flatDir { +// dirs 'lib' +// } +//} +// +//dependencies { +// testCompile 'junit:junit:4.12' +// compile 'com.google.guava:guava:19.0' +// compile 'org.apache.poi:poi:3.14' +// compile 'org.apache.poi:poi-ooxml:3.14' +// compile 'org.reflections:reflections:0.9.11' +// compile name: 'commons-cli-1.3-SNAPSHOT' +// compile name: 'zip4j_1.3.2' +// compile name: 'mockito-all-1.9.5' +//} +// +//jar { +// baseName = 'pmmanager' +// version = '0.1.0' +//} +// +//task fatJar(type: Jar) { +// manifest { +// attributes 'Implementation-Title': 'PlatformModuleManager', +// 'Implementation-Version': '1.0.0', +// 'Main-Class': 'com.gtnexus.pmm.PlatformModuleManager' +// } +// baseName = 'pmm' + '-all' +// from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } +// with jar +//} +// +//task wrapper(type: Wrapper) { +// gradleVersion = '2.3' +//} +// +//compileJava.doFirst { +// println "" +// println "on tag -> " + getVersionName() +// println "source compatibility >>" + sourceCompatibility +// println "java_home: " + System.getProperty("java.home") +// println "" +//} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e8c6bf7..f6b961f 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8b8b05a..1c50225 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Tue Oct 27 11:42:03 PDT 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip diff --git a/gradlew b/gradlew index 97fac78..cccdd3d 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -6,20 +6,38 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -150,11 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index aec9973..e95643d 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,10 +46,9 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. @@ -60,11 +59,6 @@ set _SKIP=2 if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ :execute @rem Setup the command line diff --git a/lib/commons-cli-1.3-SNAPSHOT.jar b/lib/commons-cli-1.3-SNAPSHOT.jar deleted file mode 100644 index 9a4a8f0..0000000 Binary files a/lib/commons-cli-1.3-SNAPSHOT.jar and /dev/null differ diff --git a/lib/mockito-all-1.9.5.jar b/lib/mockito-all-1.9.5.jar deleted file mode 100644 index 00416eb..0000000 Binary files a/lib/mockito-all-1.9.5.jar and /dev/null differ diff --git a/lib/zip4j_1.3.2.jar b/lib/zip4j_1.3.2.jar deleted file mode 100644 index 66a19e4..0000000 Binary files a/lib/zip4j_1.3.2.jar and /dev/null differ diff --git a/mapi/bin/.gitignore b/mapi/bin/.gitignore new file mode 100644 index 0000000..ddf9c65 --- /dev/null +++ b/mapi/bin/.gitignore @@ -0,0 +1 @@ +/main/ diff --git a/mapi/build.gradle b/mapi/build.gradle new file mode 100644 index 0000000..4fa7bc5 --- /dev/null +++ b/mapi/build.gradle @@ -0,0 +1 @@ +//placeholder diff --git a/src/main/java/com/gtnexus/appxpress/cli/FileSelector.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/FileSelector.java similarity index 78% rename from src/main/java/com/gtnexus/appxpress/cli/FileSelector.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/FileSelector.java index e40865a..a548cde 100644 --- a/src/main/java/com/gtnexus/appxpress/cli/FileSelector.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/FileSelector.java @@ -1,13 +1,13 @@ -package com.gtnexus.appxpress.cli; +package com.gtnexus.pmm.api.v100.cli; import java.io.File; import java.io.InputStream; import java.io.PrintStream; import java.util.Collection; -import com.gtnexus.appxpress.cli.asker.Asker; -import com.gtnexus.appxpress.cli.asker.BoundIntegerAsker; -import com.gtnexus.appxpress.cli.asker.SimpleAsker; +import com.gtnexus.pmm.api.v100.cli.prompt.BoundIntegerAsker; +import com.gtnexus.pmm.api.v100.cli.prompt.Prompt; +import com.gtnexus.pmm.api.v100.cli.prompt.SimplePrompt; /** * @@ -29,7 +29,7 @@ public FileSelector(BoundIntegerAsker asker) { this.asker = asker; } - public FileSelector(SimpleAsker asker) { + public FileSelector(SimplePrompt asker) { this.asker = new BoundIntegerAsker(asker); } @@ -68,9 +68,9 @@ private String createMessage(File[] choices) { * @return */ private Integer getSelectionFromUser(String message) { - Integer selection = asker.ask(message); + Integer selection = asker.prompt(message); while (selection == null) { - selection = asker.ask(Asker.INVALID_INPUT); + selection = asker.prompt(Prompt.INVALID_INPUT); } return selection - 1; } diff --git a/src/main/java/com/gtnexus/appxpress/cli/Select.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/Select.java similarity index 69% rename from src/main/java/com/gtnexus/appxpress/cli/Select.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/Select.java index 897d7f2..609aa9e 100644 --- a/src/main/java/com/gtnexus/appxpress/cli/Select.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/Select.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.cli; +package com.gtnexus.pmm.api.v100.cli; import java.util.Collection; diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/AbstractCommandOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/AbstractCommandOption.java new file mode 100644 index 0000000..9db4045 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/AbstractCommandOption.java @@ -0,0 +1,38 @@ +package com.gtnexus.pmm.api.v100.cli.option; + +public abstract class AbstractCommandOption implements CommandOption { + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("(") + .append("--") + .append(this.getLongName()) + .append(", ") + .append("-") + .append(this.getFlag()) + .append(")"); + return sb.toString(); + } + + @Override + public int hashCode() { + return this.getLongName().hashCode(); + } + + @Override + public boolean equals(Object other) { + if(other == null) { + return false; + } + if(other == this) { + //same instance + return true; + } + if(other instanceof CommandOption) { + return this.getLongName().equals(((CommandOption)other).getLongName()); + } + return false; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOption.java new file mode 100644 index 0000000..95f5321 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOption.java @@ -0,0 +1,51 @@ +package com.gtnexus.pmm.api.v100.cli.option; + +import java.util.Set; + +import com.google.common.collect.ImmutableSet; +import com.gtnexus.pmm.api.v100.cli.option.options.CustomerOption; +import com.gtnexus.pmm.api.v100.cli.option.options.HelpOption; +import com.gtnexus.pmm.api.v100.cli.option.options.LocalDirOption; +import com.gtnexus.pmm.api.v100.cli.option.options.ModuleOption; +import com.gtnexus.pmm.api.v100.cli.option.options.SelectOption; + +/** + * Extension of typical command line options interface. Holds AppXpress specific + * logic. + * + * @author jdonovan + * + */ +public interface CommandOption { + public String getLongName(); + + public String getFlag(); + + public Class getType(); + + public String getDescription(); + + public boolean hasArg(); + + public class StandardOptions { + + public static CommandOption HELP = new HelpOption(); + public static CommandOption CUSTOMER = new CustomerOption(); + public static CommandOption MODULE = new ModuleOption(); + public static CommandOption LOCAL_DIR = new LocalDirOption(); + public static CommandOption SELECT = new SelectOption(); + + private static final Set standardOpts = new ImmutableSet.Builder() + .add(HELP) + .add(CUSTOMER) + .add(MODULE) + .add(LOCAL_DIR) + .add(SELECT) + .build(); + + public static Set set() { + return standardOpts; + } + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionParser.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionParser.java new file mode 100644 index 0000000..c30156a --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionParser.java @@ -0,0 +1,79 @@ +package com.gtnexus.pmm.api.v100.cli.option; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.DefaultParser; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.ParseException; + +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +/** + * Wrapper to tie together CLICommandOptions and the Apache Commons CLI library. + * + * @author jdonovan + * + */ +public class CommandOptionParser { + + private final Set cliOptionSet; + private final Options options; + + public static CommandOptionParser createParser(Set cliOptSet) { + Options options = CommandOptionTransformers.transformToOptions(cliOptSet); + return new CommandOptionParser(cliOptSet, options); + } + + /** + * + * @param userArgs + * the args provided to main() by the user when invoking this tool + * @param cliOptionSet + * the option set defining what can be passed to this tool + */ + private CommandOptionParser(Set cliOptionSet, Options options) { + if (cliOptionSet == null) { + throw new NullPointerException("Cannot parse for null option set."); + } + this.cliOptionSet = cliOptionSet; + this.options = options; + } + + /** + * Parses the args provided by the user according to the provided option set. + * + * @throws PMExtractorException + * if input is not parasable. + */ + public Map parse(String[] userArgs) throws SubCommandException { + CommandLineParser parser = new DefaultParser(); + try { + return transform(parser.parse(options, userArgs)); + } catch (ParseException e) { + throw new SubCommandException("Failed to parse args from command line!\n" + e.getMessage()); + } + } + + public Set getCliOptionSet() { + return cliOptionSet; + } + + public Options getOptions() { + return options; + } + + private Map transform(CommandLine apacheParseResult) { + Map optMap = new HashMap<>(); + for(CommandOption opt: cliOptionSet) { + if (apacheParseResult.hasOption(opt.getLongName()) || apacheParseResult.hasOption(opt.getFlag())) { + optMap.put(opt, apacheParseResult.getOptionValue(opt.getLongName())); + } + } + return optMap; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionTransformers.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionTransformers.java new file mode 100644 index 0000000..783c899 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/CommandOptionTransformers.java @@ -0,0 +1,28 @@ +package com.gtnexus.pmm.api.v100.cli.option; + +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; + + +public class CommandOptionTransformers { + + public static Option transformToOption(CommandOption opt) { + return Option + .builder(opt.getFlag()) + .longOpt(opt.getLongName()) + .type(opt.getType()) + .desc(opt.getDescription()) + .hasArg(opt.hasArg()) + .required(false) + .build(); + } + + public static Options transformToOptions(Iterable opts) { + Options options = new Options(); + for(CommandOption opt : opts) { + options.addOption(transformToOption(opt)); + } + return options; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/CustomerOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/CustomerOption.java new file mode 100644 index 0000000..d1e5869 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/CustomerOption.java @@ -0,0 +1,33 @@ +package com.gtnexus.pmm.api.v100.cli.option.options; + +import com.gtnexus.pmm.api.v100.cli.option.AbstractCommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public class CustomerOption extends AbstractCommandOption implements CommandOption { + + @Override + public String getLongName() { + return "customer"; + } + + @Override + public String getFlag() { + return "c"; + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String getDescription() { + return "The customer who owns this module"; + } + + @Override + public boolean hasArg() { + return true; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/HelpOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/HelpOption.java new file mode 100644 index 0000000..af1d678 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/HelpOption.java @@ -0,0 +1,33 @@ +package com.gtnexus.pmm.api.v100.cli.option.options; + +import com.gtnexus.pmm.api.v100.cli.option.AbstractCommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public class HelpOption extends AbstractCommandOption implements CommandOption { + + @Override + public String getLongName() { + return "help"; + } + + @Override + public String getFlag() { + return "h"; + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String getDescription() { + return "Display usage for this tool"; + } + + @Override + public boolean hasArg() { + return false; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/LocalDirOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/LocalDirOption.java new file mode 100644 index 0000000..abef36b --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/LocalDirOption.java @@ -0,0 +1,36 @@ +package com.gtnexus.pmm.api.v100.cli.option.options; + +import com.gtnexus.pmm.api.v100.cli.option.AbstractCommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public class LocalDirOption extends AbstractCommandOption implements CommandOption { + + public static final String NAME = "localDir"; + public static final String FLAG = "ld"; + + @Override + public String getLongName() { + return NAME; + } + + @Override + public String getFlag() { + return FLAG; + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String getDescription() { + return "Relative path of git staging folder."; + } + + @Override + public boolean hasArg() { + return true; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/ModuleOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/ModuleOption.java new file mode 100644 index 0000000..594449e --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/ModuleOption.java @@ -0,0 +1,33 @@ +package com.gtnexus.pmm.api.v100.cli.option.options; + +import com.gtnexus.pmm.api.v100.cli.option.AbstractCommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public class ModuleOption extends AbstractCommandOption implements CommandOption { + + @Override + public String getLongName() { + return "module"; + } + + @Override + public String getFlag() { + return "m"; + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String getDescription() { + return "The name of the module"; + } + + @Override + public boolean hasArg() { + return true; + } + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/SelectOption.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/SelectOption.java new file mode 100644 index 0000000..a0279c0 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/option/options/SelectOption.java @@ -0,0 +1,33 @@ +package com.gtnexus.pmm.api.v100.cli.option.options; + +import com.gtnexus.pmm.api.v100.cli.option.AbstractCommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public class SelectOption extends AbstractCommandOption implements CommandOption { + + @Override + public String getLongName() { + return "select"; + } + + @Override + public String getFlag() { + return "s"; + } + + @Override + public Class getType() { + return Integer.class; + } + + @Override + public String getDescription() { + return "Select module from the folders present in the cwd."; + } + + @Override + public boolean hasArg() { + return false; + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/BoundIntegerAsker.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/BoundIntegerAsker.java similarity index 84% rename from src/main/java/com/gtnexus/appxpress/cli/asker/BoundIntegerAsker.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/BoundIntegerAsker.java index 9092103..bf7d64d 100644 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/BoundIntegerAsker.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/BoundIntegerAsker.java @@ -1,9 +1,9 @@ -package com.gtnexus.appxpress.cli.asker; +package com.gtnexus.pmm.api.v100.cli.prompt; import java.io.InputStream; import java.io.PrintStream; -public class BoundIntegerAsker extends IntegerAsker { +public class BoundIntegerAsker extends IntegerPrompt { private Integer high, low; @@ -17,7 +17,7 @@ public BoundIntegerAsker(InputStream in, PrintStream out) { super(in, out); } - public BoundIntegerAsker(SimpleAsker asker) { + public BoundIntegerAsker(SimplePrompt asker) { super(asker); } diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/IntegerPrompt.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/IntegerPrompt.java new file mode 100644 index 0000000..947a3b4 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/IntegerPrompt.java @@ -0,0 +1,25 @@ +package com.gtnexus.pmm.api.v100.cli.prompt; + +import java.io.InputStream; +import java.io.PrintStream; + +public class IntegerPrompt extends SimpleTypedPrompt { + + public IntegerPrompt(InputStream in, PrintStream out) { + super(in, out); + } + + public IntegerPrompt(SimplePrompt asker) { + super(asker); + } + + @Override + protected Integer convert(String m) { + Integer r = null; + try { + r = Integer.valueOf(m); + } catch (NumberFormatException e) {} + return r; + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/Asker.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/Prompt.java similarity index 52% rename from src/main/java/com/gtnexus/appxpress/cli/asker/Asker.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/Prompt.java index 140daa5..045fc60 100644 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/Asker.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/Prompt.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.cli.asker; +package com.gtnexus.pmm.api.v100.cli.prompt; /** * @@ -6,10 +6,10 @@ * * @param */ -public interface Asker { +public interface Prompt { public static final String INVALID_INPUT = "Invalid input. Please try again."; - public T ask(String message); + public T prompt(String message); } diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/SimpleAsker.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimplePrompt.java similarity index 61% rename from src/main/java/com/gtnexus/appxpress/cli/asker/SimpleAsker.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimplePrompt.java index bc371a4..0b3fb6c 100644 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/SimpleAsker.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimplePrompt.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.cli.asker; +package com.gtnexus.pmm.api.v100.cli.prompt; import java.io.InputStream; import java.io.PrintStream; @@ -7,18 +7,18 @@ /** * Created by jjdonov on 9/30/14. */ -public class SimpleAsker implements Asker { +public class SimplePrompt implements Prompt { private final Scanner scanner; private final PrintStream out; - public SimpleAsker(InputStream in, PrintStream out) { + public SimplePrompt(InputStream in, PrintStream out) { this.scanner = new Scanner(in); this.out = out; } @Override - public String ask(String message) { + public String prompt(String message) { out.println(message); return scanner.next(); } diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimpleTypedPrompt.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimpleTypedPrompt.java new file mode 100644 index 0000000..51baab5 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/cli/prompt/SimpleTypedPrompt.java @@ -0,0 +1,26 @@ +package com.gtnexus.pmm.api.v100.cli.prompt; + +import java.io.InputStream; +import java.io.PrintStream; + +public abstract class SimpleTypedPrompt implements Prompt { + + private SimplePrompt asker; + + public SimpleTypedPrompt(InputStream in, PrintStream out) { + this.asker = new SimplePrompt(in, out); + } + + public SimpleTypedPrompt(SimplePrompt asker) { + this.asker = asker; + } + + @Override + public T prompt(String message) { + String result = asker.prompt(message); + return convert(result); + } + + protected abstract T convert(String m); + +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/AbstractSubCommand.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/AbstractSubCommand.java new file mode 100644 index 0000000..3102cf9 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/AbstractSubCommand.java @@ -0,0 +1,51 @@ +package com.gtnexus.pmm.api.v100.command; + +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Preconditions; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOptionParser; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; + +public abstract class AbstractSubCommand implements SubCommand { + + private final PlatformModuleManagerServices services; + private final String[] args; + + public AbstractSubCommand(PlatformModuleManagerServices services, String ...args) { + Preconditions.checkNotNull(services); + Preconditions.checkNotNull(args); + this.services = services; + this.args = args; + } + + protected final PlatformModuleManagerServices getServices() { + return this.services; + } + + protected final String[] getArgs() { + return this.args; + } + + protected Map parse() throws SubCommandException { + return CommandOptionParser + .createParser(this.getOptions()) + .parse(this.args); + } + + @Override + public Set getOptions() { + return CommandOption.StandardOptions.set(); + } + + @Override + public String getHelpHeader() { + return ""; + } + + @Override + public String getHelpFooter() { + return ""; + } +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommand.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommand.java new file mode 100644 index 0000000..18ab162 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommand.java @@ -0,0 +1,17 @@ +package com.gtnexus.pmm.api.v100.command; + +import java.util.Set; + +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public interface SubCommand { + public String getName(); + + public String getHelpHeader(); + + public String getHelpFooter(); + + public Set getOptions(); + + public void execute() throws SubCommandException; //TODO: throw subcommand exception? +} diff --git a/src/main/java/com/gtnexus/appxpress/exception/AppXpressException.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandException.java similarity index 54% rename from src/main/java/com/gtnexus/appxpress/exception/AppXpressException.java rename to mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandException.java index e0eca4c..176876b 100644 --- a/src/main/java/com/gtnexus/appxpress/exception/AppXpressException.java +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandException.java @@ -1,29 +1,29 @@ -package com.gtnexus.appxpress.exception; +package com.gtnexus.pmm.api.v100.command; -public class AppXpressException extends Exception { +public class SubCommandException extends Exception { /** * */ private static final long serialVersionUID = 2917655270465043358L; - public AppXpressException() { + public SubCommandException() { super(); } - public AppXpressException(String arg0, Throwable arg1, boolean arg2, boolean arg3) { + public SubCommandException(String arg0, Throwable arg1, boolean arg2, boolean arg3) { super(arg0, arg1, arg2, arg3); } - public AppXpressException(String arg0, Throwable arg1) { + public SubCommandException(String arg0, Throwable arg1) { super(arg0, arg1); } - public AppXpressException(String arg0) { + public SubCommandException(String arg0) { super(arg0); } - public AppXpressException(Throwable arg0) { + public SubCommandException(Throwable arg0) { super(arg0); } diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandMarker.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandMarker.java new file mode 100644 index 0000000..bfaa106 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/command/SubCommandMarker.java @@ -0,0 +1,14 @@ +package com.gtnexus.pmm.api.v100.command; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface SubCommandMarker { + String name(); + String flag() default ""; + String description(); +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/EnvironmentService.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/EnvironmentService.java new file mode 100644 index 0000000..3d668d9 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/EnvironmentService.java @@ -0,0 +1,12 @@ +package com.gtnexus.pmm.api.v100.service; +import java.nio.file.Path; +import java.util.Properties; + +public interface EnvironmentService { + public Path getLocalDir(); + public Path getCWD(); + public Path getAppXDir(); + public Path getLibPath(); + public Properties getProperties(); + public String[] getRawArgs(); +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/FileService.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/FileService.java new file mode 100644 index 0000000..cb4917d --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/FileService.java @@ -0,0 +1,171 @@ +package com.gtnexus.pmm.api.v100.service; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; + +import com.google.common.base.Predicate; + +public interface FileService { + + /** + * Prepends a String to the front of a single file. + * + * @param file + * The file whose name will be altered. + * @param prepend + * The String to prepend to the file's name. + */ + Path prependToName(File file, String prepend) throws IOException; + + Path prependToName(File file, String prepend, Predicate precondition) throws IOException; + + /** + * Prepends a String to the the names of a collection of a files. + * + * @param files + * The list of files who's name will be altered. + * @param prepend + * The String to prepend to each file name. + */ + List prependToName(Collection files, String prepend) throws IOException; + + /** + * Prepends a String to the the names of a collection of a files. + * + * @param files + * The list of files who's name will be altered. + * @param prepend + * The String to prepend to each file name. + * @precondition The condition that must be met before string is prepended to + * file name + */ + List prependToName(Collection files, String prepend, Predicate precondition) + throws IOException; + + /** + * Rename a single file + * + * @param file + * The file whose name will be altered. + * @param newName + * The files new name. + * @throws IOException + * if the renaming operation fails. + */ + Path renameFile(File file, String newName) throws IOException; + + /** + * Rename a single file + * + * @param file + * The file whose name will be altered. + * @param newName + * The files new name. + * @throws IOException + * if the renaming operation fails. + */ + Path renameFile(File file, String newName, Predicate precondition) throws IOException; + + /** + * Renames a set of files by replacing a matched string with some replacement. + * + * @param files + * The set of file's whose names will be altered if they match the + * replacement string. + * @param toReplace + * The string that will be replaced if found in any file names. + * @param replacement + * The string that will replace the found string in the file name. + */ + List renameFile(Collection files, String toReplace, String replacement) throws IOException; + + /** + * Renames a set of files by replacing a matched string with some replacement as + * long as some precondition is met for each file. + * + * @param files + * The set of file's whose names will be altered if they match the + * replacement string. + * @param toReplace + * The string that will be replaced if found in any file names. + * @param replacement + * The string that will replace the found string in the file name. + * @param precondition + * The precondition that must be met in order for file to be renamed. + */ + List renameFile(Collection files, String toReplace, String replacement, + Predicate precondition) throws IOException; + + /** + * + * @param files + * The files to be copied. + * @param destination + * The destination directory. + * @return The list of paths to the the copied files. + * @throws IOException + * @throws IllegalArgumentDestination + * If destination is not a directory. + */ + List moveFiles(Collection files, File destination) throws IOException; + + /** + * + * @param files + * @param destination + * @param precondition + * @return + * @throws IOException + */ + List copyFiles(Collection files, File destination, + Predicate precondition) throws IOException; + + /** + * + * @param sourceDir + * @param destination + * @return + * @throws IOException + */ + Path copyDirectory(File sourceDir, File destination) throws IOException; + + /** + * + * @param source + * @param destination + * @return + * @throws IOException + */ + Path copyDirectory(Path source, Path destination) throws IOException; + + /** + * + * @param file + * @param mimeType + * @return + */ + boolean isFileType(File file, String extension); + + /** + * + * @param root + * @throws IOException + */ + void emptyDir(File root) throws IOException; + + void emptyDir(Path root) throws IOException; + + /** + * + * @param root + * @param deleteRoot + * @throws IOException + */ + void emptyDir(File root, boolean deleteRoot) throws IOException; + + void emptyDir(Path root, boolean deleteRoot) throws IOException; + +} \ No newline at end of file diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/PlatformModuleManagerServices.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/PlatformModuleManagerServices.java new file mode 100644 index 0000000..9250ace --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/PlatformModuleManagerServices.java @@ -0,0 +1,11 @@ +package com.gtnexus.pmm.api.v100.service; + +public interface PlatformModuleManagerServices { + public ZipService getZipService(); + public FileService getFileService(); + public TemporaryResourceService getTemporaryResourceService(); + public EnvironmentService getEnvironmentService(); + + //public SelectorService getPromptService(); for Select + //public CleanupService getCleanupService +} diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/TemporaryResourceService.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/TemporaryResourceService.java new file mode 100644 index 0000000..0219842 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/TemporaryResourceService.java @@ -0,0 +1,9 @@ +package com.gtnexus.pmm.api.v100.service; + +import java.io.File; + +public interface TemporaryResourceService { + + public void markForDeletion(File f); + +} \ No newline at end of file diff --git a/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/ZipService.java b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/ZipService.java new file mode 100644 index 0000000..ac9e517 --- /dev/null +++ b/mapi/src/main/java/com/gtnexus/pmm/api/v100/service/ZipService.java @@ -0,0 +1,48 @@ +package com.gtnexus.pmm.api.v100.service; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; + +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +public interface ZipService { + + void zipFiles(Collection files, String absPathToDestinationZip) throws SubCommandException; + + void zipDirectory(Path directory) throws SubCommandException; + + /** + * Packs the given directory into a a zip file named after the directory. + * + * @param directoryPath + * - the directory that is going to be packed + * @throws IOException + */ + void zipDirectory(File directory) throws SubCommandException; + + /** + * Packs the given directory into a a zip file named after the directory. + * + * @param directoryPath + * - the directory that is going to be packed + * @throws IOException + */ + void zipDirectory(File directory, String outputZip) throws SubCommandException; + + /** + * Packs the given directory into the zip file pointer. If the outputZip does + * not end with .zip it is appended. + * + * @param directory + * @param outputZip + * @throws SubCommandException + */ + void zipDirectory(File directory, File outputZip) throws SubCommandException; + + void unzip(File source, File destination, boolean recurse) throws SubCommandException; + + void unzip(File source, File destination) throws SubCommandException; + +} \ No newline at end of file diff --git a/mapp/bin/.gitignore b/mapp/bin/.gitignore new file mode 100644 index 0000000..7eed456 --- /dev/null +++ b/mapp/bin/.gitignore @@ -0,0 +1,2 @@ +/main/ +/test/ diff --git a/src/main/java/com/gtnexus/appxpress/AppXpressConstants.java b/mapp/src/main/java/com/gtnexus/pmm/app/AppXpressConstants.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/AppXpressConstants.java rename to mapp/src/main/java/com/gtnexus/pmm/app/AppXpressConstants.java index c2b31fd..2ae00e4 100644 --- a/src/main/java/com/gtnexus/appxpress/AppXpressConstants.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/AppXpressConstants.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress; +package com.gtnexus.pmm.app; import java.io.File; import java.util.Set; @@ -37,6 +37,9 @@ public interface AppXpressConstants { public static final String XML_EXTENSION = ".xml"; public static final String ZIP_EXTENSION = ".zip"; - public static final Set IGNORE_SET = new ImmutableSet.Builder().add("_MACOSX").add("__MACOSX") - .add(".DS_Store").build(); + public static final Set IGNORE_SET = new ImmutableSet.Builder() + .add("_MACOSX") + .add("__MACOSX") + .add(".DS_Store") + .build(); } diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/PlatformModuleManager.java b/mapp/src/main/java/com/gtnexus/pmm/app/PlatformModuleManager.java new file mode 100644 index 0000000..97bdbbf --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/PlatformModuleManager.java @@ -0,0 +1,87 @@ +package com.gtnexus.pmm.app; + +import java.util.HashSet; +import java.util.Set; + +import com.gtnexus.pmm.api.v100.command.SubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.manager.DirectoryHelper; +import com.gtnexus.pmm.app.manager.Help; +import com.gtnexus.pmm.app.manager.SubCommandScanner; +import com.gtnexus.pmm.app.manager.command.CLICommand; +import com.gtnexus.pmm.app.manager.command.CommandIdentifier; +import com.gtnexus.pmm.app.service.PlatformModuleManagerServicesImpl; + +public class PlatformModuleManager { + + public static void main(String... args) { + try { + PlatformModuleManager pmm = start(args); + pmm.run(); + } catch (SubCommandException e) { + System.out.println("Failed to start."); + } + } + + public static PlatformModuleManager start(String... args) throws SubCommandException { + DirectoryHelper dHelper = new DirectoryHelper(); + dHelper.ensureAppXpress(); + Set commands = SubCommandScanner.scan(); + Help help = new Help(commands); + PlatformModuleManagerServicesImpl services = new PlatformModuleManagerServicesImpl(dHelper.getPmProperties(), args); + return new PlatformModuleManager(services, commands, help); + } + + private final PlatformModuleManagerServices services; + private final Set commands; + private final Help help; + + public PlatformModuleManager(PlatformModuleManagerServices services, Set commands, Help help) { + this.services = services; + this.commands = commands; + this.help = help; + } + + public String[] getRawArgs() { + return this.services.getEnvironmentService().getRawArgs(); + } + + public PlatformModuleManagerServices getServices() { + return this.services; + } + + Help getHelp() { + return this.help; + } + + protected void run() { + try { + PlatformModuleManager.getCommand(this).execute(); + } catch (SubCommandException e) { + System.out.println(e.getAppXpressMessage()); + } + } + + public static SubCommand getCommand(PlatformModuleManager pmm) { + SubCommand cmd; + String[] args = pmm.getRawArgs(); + if (args.length > 0) { + String cmdNameOrFlag = args[0]; + Set allCmds = new HashSet<>(pmm.getCommands()); + allCmds.add(pmm.getHelp()); + CLICommand cliCmd = new CommandIdentifier(allCmds) + .identify(cmdNameOrFlag) + .or(pmm.getHelp()); + cmd = cliCmd.constructCommand(pmm.getServices(), args); + } else { + cmd = pmm.getHelp().constructCommand(pmm.getServices(), args); + } + return cmd; + } + + public Set getCommands() { + //return PlatformModuleManagerCommand.getAllCommands(); + return this.commands; + } +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/common/CommandOptionCompleter.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/CommandOptionCompleter.java new file mode 100644 index 0000000..7cd1bf9 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/CommandOptionCompleter.java @@ -0,0 +1,119 @@ +package com.gtnexus.pmm.app.common; + +import java.nio.file.Path; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption.StandardOptions; +import com.gtnexus.pmm.api.v100.cli.prompt.Prompt; +import com.gtnexus.pmm.api.v100.cli.prompt.SimplePrompt; +import com.gtnexus.pmm.api.v100.service.EnvironmentService; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; + +public class CommandOptionCompleter { + + private final PlatformModuleManagerServices services; + private final Set requiredOptions; + private final Map defaults; + + public CommandOptionCompleter(PlatformModuleManagerServices services, Set requiredOptions) { + this(services, requiredOptions, Collections.emptyMap()); + } + + + public CommandOptionCompleter(PlatformModuleManagerServices services, Set requiredOptions, Map defaults) { + this.services = services; + this.requiredOptions = requiredOptions; + this.defaults = defaults; + } + + public Map complete(final Map options) { + Map consolidated = new HashMap<>(options); + if (!consolidated.containsKey(StandardOptions.LOCAL_DIR)) { + consolidated.put(StandardOptions.LOCAL_DIR, services.getEnvironmentService().getLocalDir().toString()); + } + inheritOptionsFromWorkingDir(consolidated); + if (consolidated.containsKey(StandardOptions.SELECT)) { + doSelect(consolidated); + } + for(CommandOption requiredOption : requiredOptions) { + if(!consolidated.containsKey(requiredOption)) { + consolidated.put(requiredOption, getParameterFromUser(requiredOption)); + } + } + for(Entry entry : defaults.entrySet()) { + if(!consolidated.containsKey(entry.getKey())) { + consolidated.put(entry.getKey(), entry.getValue()); + } + } + return consolidated; + } + + private void doSelect(Map consolidated) { + throw new RuntimeException("Unimplemented"); + } + + protected void inheritOptionsFromWorkingDir(Map consolidated) { + if(consolidated.containsKey(StandardOptions.CUSTOMER) && consolidated.containsKey(StandardOptions.MODULE)) { + return; + } + EnvironmentService environmentService = services.getEnvironmentService(); + Path cwd = environmentService.getCWD().toAbsolutePath(); + Path localDir = environmentService.getLocalDir().toAbsolutePath(); + if(!cwd.equals(localDir) && cwd.startsWith(localDir)) { + Path parent = cwd.getParent(); + if(parent.endsWith("customer")) { + consolidated.put(StandardOptions.CUSTOMER, filename(cwd)); + } else if(parent.getParent().endsWith("customer")) { + consolidated.put(StandardOptions.CUSTOMER, filename(parent)); + consolidated.put(StandardOptions.MODULE, filename(cwd)); + } + } + } + + private String filename(Path p) { + return p.getFileName().toString(); + } + + private String getParameterFromUser(CommandOption option) { + Prompt p = new SimplePrompt(System.in, System.out); + String val = p.prompt(getMessage(option)); + while (!isValid(val, option.getType())) { + val = p.prompt(Prompt.INVALID_INPUT); + } + return val; + } + + private String getMessage(CommandOption option) { + Class type = option.getType(); + String name = option.getLongName(); + if (type.equals(Integer.class)) { + return ("Please enter the number of " + name + "(s): "); + } else if (type.equals(String.class)) { + return ("Please enter " + name + ": "); + } else if (type.equals(Boolean.class)) { + return ("Do you want " + name + "? [y/n]: "); + } + throw new IllegalArgumentException("Option type" + type.toString() + " is unsupported"); + } + + public boolean isValid(String val, Class type) { + if (val == null || val.length() == 0) { + return false; + } + if (type.equals(String.class)) { + return true; + } + if (type.equals(Integer.class)) { + return val.matches("\\d+"); + } else if (type.equals(Boolean.class)) { + return val.equalsIgnoreCase("Y") || val.equalsIgnoreCase("N"); + } else { + return false; + } + } +} diff --git a/src/main/java/com/gtnexus/appxpress/commons/properties/PMProperties.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/PMProperties.java similarity index 79% rename from src/main/java/com/gtnexus/appxpress/commons/properties/PMProperties.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/PMProperties.java index 62e18e1..3959463 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/properties/PMProperties.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/PMProperties.java @@ -1,12 +1,12 @@ -package com.gtnexus.appxpress.commons.properties; +package com.gtnexus.pmm.app.common; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.command.SubCommandException; /** * Simple wrapper around a File and Property objects. @@ -41,7 +41,7 @@ public String getProperty(String property) { return properties.getProperty(property); } - public String getProperty(CLICommandOption opt) { + public String getProperty(CommandOption opt) { return properties.getProperty(opt.getLongName()); } @@ -52,11 +52,11 @@ public void put(String key, String value) { properties.put(key, value); } - public void store() throws AppXpressException { + public void store() throws SubCommandException { try (FileOutputStream settingsOutputStream = new FileOutputStream(propertiesFile)) { properties.store(settingsOutputStream, null); } catch (IOException e) { - throw new AppXpressException("Failed to write properties file!", e); + throw new SubCommandException("Failed to write properties file!", e); } } diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/common/SubCommandHelpFormatter.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/SubCommandHelpFormatter.java new file mode 100644 index 0000000..a311971 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/SubCommandHelpFormatter.java @@ -0,0 +1,24 @@ +package com.gtnexus.pmm.app.common; + +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; + +import com.gtnexus.pmm.api.v100.cli.option.CommandOptionTransformers; +import com.gtnexus.pmm.api.v100.command.SubCommand; + +public class SubCommandHelpFormatter { + + private final SubCommand cmd; + + public SubCommandHelpFormatter(SubCommand cmd) { + this.cmd = cmd; + } + + public void displayHelp() { + HelpFormatter helpFormatter = new HelpFormatter(); + Options opts = CommandOptionTransformers.transformToOptions(cmd.getOptions()); + helpFormatter.printHelp(cmd.getName(), cmd.getHelpHeader(), opts, cmd.getHelpFooter()); + return; + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/CopyDirVisitor.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/CopyDirVisitor.java similarity index 86% rename from src/main/java/com/gtnexus/appxpress/commons/file/CopyDirVisitor.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/CopyDirVisitor.java index 03e0773..22ad7f2 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/CopyDirVisitor.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/CopyDirVisitor.java @@ -1,6 +1,6 @@ -package com.gtnexus.appxpress.commons.file; +package com.gtnexus.pmm.app.common.file; -import static com.gtnexus.appxpress.AppXpressConstants.IGNORE_SET; +import static com.gtnexus.pmm.app.AppXpressConstants.IGNORE_SET; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -41,7 +41,7 @@ public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttribut @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Path target = destination.resolve(source.relativize(file)); - if (!IGNORE_SET.contains(file.getFileName())) { + if (!IGNORE_SET.contains(file.getFileName().toString())) { Files.copy(file, target, replace); } return FileVisitResult.CONTINUE; diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/DeleteDirVisitor.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/DeleteDirVisitor.java similarity index 91% rename from src/main/java/com/gtnexus/appxpress/commons/file/DeleteDirVisitor.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/DeleteDirVisitor.java index ddcefc8..182f3ba 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/DeleteDirVisitor.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/DeleteDirVisitor.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.file; +package com.gtnexus.pmm.app.common.file; import java.io.IOException; import java.nio.file.FileVisitResult; diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/FileCleanup.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/FileCleanup.java similarity index 74% rename from src/main/java/com/gtnexus/appxpress/commons/file/FileCleanup.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/FileCleanup.java index 4ba3d4f..6d64335 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/FileCleanup.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/FileCleanup.java @@ -1,10 +1,13 @@ -package com.gtnexus.appxpress.commons.file; +package com.gtnexus.pmm.app.common.file; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.Iterator; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.app.service.FileServiceImpl; + /** * * @author jdonovan @@ -15,7 +18,7 @@ public class FileCleanup { private final FileService fs; public FileCleanup() { - this.fs = new FileService(); + this.fs = new FileServiceImpl(); } public void cleanup(Collection files) { diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedAnd.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedAnd.java similarity index 88% rename from src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedAnd.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedAnd.java index 1f4d032..111c755 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedAnd.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedAnd.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.file.filter; +package com.gtnexus.pmm.app.common.file.filter; import java.io.File; import java.io.FileFilter; diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedOr.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedOr.java similarity index 87% rename from src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedOr.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedOr.java index d9bc74b..d46cd26 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/filter/ChainedOr.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/ChainedOr.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.file.filter; +package com.gtnexus.pmm.app.common.file.filter; import java.io.File; import java.io.FileFilter; diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterChain.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterChain.java similarity index 92% rename from src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterChain.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterChain.java index b43ab50..3e9712e 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterChain.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterChain.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.file.filter; +package com.gtnexus.pmm.app.common.file.filter; import java.io.File; import java.io.FileFilter; diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterFactory.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterFactory.java index 553038c..2bd3a60 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/file/filter/FileFilterFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/file/filter/FileFilterFactory.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.file.filter; +package com.gtnexus.pmm.app.common.file.filter; import java.io.File; import java.io.FileFilter; diff --git a/src/main/java/com/gtnexus/appxpress/commons/properties/PropertiesPersister.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/properties/PropertiesPersister.java similarity index 53% rename from src/main/java/com/gtnexus/appxpress/commons/properties/PropertiesPersister.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/properties/PropertiesPersister.java index ca50395..6d5b2b3 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/properties/PropertiesPersister.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/properties/PropertiesPersister.java @@ -1,17 +1,18 @@ -package com.gtnexus.appxpress.commons.properties; +package com.gtnexus.pmm.app.common.properties; -import com.gtnexus.appxpress.cli.asker.Asker; -import com.gtnexus.appxpress.cli.asker.SimpleAsker; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.exception.PMExtractorException; +import com.gtnexus.pmm.api.v100.cli.prompt.Prompt; +import com.gtnexus.pmm.api.v100.cli.prompt.SimplePrompt; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.common.PMProperties; +import com.gtnexus.pmm.app.extract.exception.PMExtractorException; public class PropertiesPersister { - private Asker asker; + private Prompt asker; private PMProperties properties; public PropertiesPersister(PMProperties properties) { - this.asker = new SimpleAsker(System.in, System.out); + this.asker = new SimplePrompt(System.in, System.out); this.properties = properties; } @@ -22,7 +23,7 @@ public PropertiesPersister(PMProperties properties) { * when there is an IOException when writing to the properties file * at the propPath. */ - public void presentSaveOption() throws AppXpressException { + public void presentSaveOption() throws SubCommandException { final String answer = askSaveQuestion(); if (answer.equalsIgnoreCase("Y")) { saveProps(); @@ -33,7 +34,7 @@ public void presentSaveOption() throws AppXpressException { * * @throws PMExtractorException */ - private void saveProps() throws AppXpressException { + private void saveProps() throws SubCommandException { properties.store(); } @@ -42,9 +43,9 @@ private void saveProps() throws AppXpressException { * @return */ private String askSaveQuestion() { - String answer = asker.ask("Save settings? [y/n]: "); + String answer = asker.prompt("Save settings? [y/n]: "); while (!answer.equalsIgnoreCase("Y") && !answer.equalsIgnoreCase("N")) { - answer = asker.ask(Asker.INVALID_INPUT); + answer = asker.prompt(Prompt.INVALID_INPUT); } return answer; } diff --git a/src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdown.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdown.java similarity index 66% rename from src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdown.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdown.java index 8baaa74..5cf6eaa 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdown.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdown.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.runtime; +package com.gtnexus.pmm.app.common.runtime; public interface SimpleShutdown { diff --git a/src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdownImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdownImpl.java similarity index 81% rename from src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdownImpl.java rename to mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdownImpl.java index 95d050e..bf71822 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/runtime/SimpleShutdownImpl.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/common/runtime/SimpleShutdownImpl.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons.runtime; +package com.gtnexus.pmm.app.common.runtime; public class SimpleShutdownImpl implements SimpleShutdown { diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/docgen/DocGenCommand.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/DocGenCommand.java new file mode 100644 index 0000000..5643da6 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/DocGenCommand.java @@ -0,0 +1,92 @@ +package com.gtnexus.pmm.app.docgen; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Map; +import java.util.Set; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.google.common.collect.ImmutableSet; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption.StandardOptions; +import com.gtnexus.pmm.api.v100.command.AbstractSubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.command.SubCommandMarker; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.common.CommandOptionCompleter; +import com.gtnexus.pmm.app.common.SubCommandHelpFormatter; +import com.gtnexus.pmm.app.platform.module.ModulePointer; +import com.gtnexus.pmm.app.platform.module.ModuleVO; +import com.gtnexus.pmm.app.platform.module.interpretation.PlatformModuleInterpreter; + +/** + * Generates documentation for the given platform module. + * + * Currently only supporting excel, but is open to supporting other formats in + * the future. + * + * @author jdonovan + */ +@SubCommandMarker( + name = DocGenCommand.NAME, + description = "generates docs/specs for a given platform module" +) +public class DocGenCommand extends AbstractSubCommand { + + public static final String NAME = "docgen"; + + private final WorkbookRenderer renderer; + + private static final Set requiredOptions = new ImmutableSet.Builder() + .add(StandardOptions.LOCAL_DIR) + .add(StandardOptions.CUSTOMER) + .add(StandardOptions.MODULE) + .build(); + + public DocGenCommand(PlatformModuleManagerServices services, String... args) { + super(services, args); + this.renderer = new WorkbookRenderer(); + } + + @Override + public void execute() throws SubCommandException { + // attachCleanUpHook(context); + Map optionsMap = this.parse(); + if(optionsMap.containsKey(StandardOptions.HELP)) { + new SubCommandHelpFormatter(this).displayHelp(); + return; + } + optionsMap = new CommandOptionCompleter(getServices(), requiredOptions).complete(optionsMap); + ModulePointer pointer = ModulePointer.make(optionsMap); + PlatformModuleInterpreter interp = new PlatformModuleInterpreter(pointer); + ModuleVO vo = interp.interpret(); + XSSFWorkbook wb = renderer.render(vo); + File file = new File(fileName(optionsMap)); + try (FileOutputStream fileOut = new FileOutputStream(file)) { + wb.write(fileOut); + } catch (IOException e) { + throw new SubCommandException("Failed to write documentation to file.", e); + } + System.out.println("Success! Documentation written to " + file.toPath().toAbsolutePath().toString()); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public Set getOptions() { + return StandardOptions.set(); + } + + private String fileName(Map optMap) { + String fileNameTemplate = "%s-%s-TechnicalSpecification.xlsx"; + String customer = optMap.get(StandardOptions.CUSTOMER); + String module = optMap.get(StandardOptions.MODULE); + return String.format(fileNameTemplate, customer, module); + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/WorkbookRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/WorkbookRenderer.java similarity index 76% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/WorkbookRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/WorkbookRenderer.java index 94ba125..0da2cae 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/WorkbookRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/WorkbookRenderer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen; +package com.gtnexus.pmm.app.docgen; import java.util.Collections; import java.util.LinkedList; @@ -9,17 +9,17 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; -import com.gtnexus.appxpress.platform.module.ModuleVO; -import com.gtnexus.appxpress.platform.module.interpretation.CustomObjectDesignV110Comparator; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.ChangeLogRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.CustomActionDocRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.CustomLinkDocRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.CustomObjectDesignDocRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.TemplatesRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.TopicsRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.TypeExtensionDocRenderer; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.UserInterfacesRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.ChangeLogRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.CustomActionDocRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.CustomLinkDocRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.CustomObjectDesignDocRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.TemplatesRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.TopicsRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.TypeExtensionDocRenderer; +import com.gtnexus.pmm.app.docgen.renderer.excel.UserInterfacesRenderer; +import com.gtnexus.pmm.app.platform.module.ModuleVO; +import com.gtnexus.pmm.app.platform.module.interpretation.CustomObjectDesignV110Comparator; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; public class WorkbookRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/AttachmentFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/AttachmentFeatureDisplayAdapter.java similarity index 85% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/AttachmentFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/AttachmentFeatureDisplayAdapter.java index 1755aa8..6af0b28 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/AttachmentFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/AttachmentFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.AttachmentFeature; +import com.gtnexus.pmm.app.platform.module.model.design.AttachmentFeature; public class AttachmentFeatureDisplayAdapter extends DisplayAdapter { private static final Function IS_ENABLED_FN = new BooleanDisplayFunction() { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/BooleanDisplayFunction.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/BooleanDisplayFunction.java similarity index 87% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/BooleanDisplayFunction.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/BooleanDisplayFunction.java index 1d48d1e..9cc1a6a 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/BooleanDisplayFunction.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/BooleanDisplayFunction.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import com.google.common.base.Function; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomActionD1DisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomActionD1DisplayAdapter.java similarity index 94% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomActionD1DisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomActionD1DisplayAdapter.java index a2bedaf..5fcdaf8 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomActionD1DisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomActionD1DisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.customaction.CustomActionD1; +import com.gtnexus.pmm.app.platform.module.model.customaction.CustomActionD1; public class CustomActionD1DisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomLinkD1DisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomLinkD1DisplayAdapter.java similarity index 94% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomLinkD1DisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomLinkD1DisplayAdapter.java index 0eba401..67f8871 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomLinkD1DisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomLinkD1DisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.customlink.CustomLinkD1; +import com.gtnexus.pmm.app.platform.module.model.customlink.CustomLinkD1; public class CustomLinkD1DisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomObjectDesignV110DisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomObjectDesignV110DisplayAdapter.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomObjectDesignV110DisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomObjectDesignV110DisplayAdapter.java index 6795868..8f161fb 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomObjectDesignV110DisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomObjectDesignV110DisplayAdapter.java @@ -1,12 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; -import com.gtnexus.appxpress.pmdocgen.adapter.PrimitiveDisplayFunction; -import com.gtnexus.appxpress.platform.module.model.design.Anchor; -import com.gtnexus.appxpress.platform.module.model.design.CodSection; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.design.Anchor; +import com.gtnexus.pmm.app.platform.module.model.design.CodSection; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; public abstract class CustomObjectDesignV110DisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomUiConfigurationDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomUiConfigurationDisplayAdapter.java similarity index 91% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomUiConfigurationDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomUiConfigurationDisplayAdapter.java index d91a106..b645753 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/CustomUiConfigurationDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/CustomUiConfigurationDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.platformmodule.CustomUiConfiguration; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.CustomUiConfiguration; public class CustomUiConfigurationDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/DisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/DisplayAdapter.java similarity index 94% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/DisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/DisplayAdapter.java index bc353d7..bb6a6cf 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/DisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/DisplayAdapter.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Iterator; import java.util.Map; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EdgeDescriptorDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EdgeDescriptorDisplayAdapter.java similarity index 69% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EdgeDescriptorDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EdgeDescriptorDisplayAdapter.java index 64cace5..adbe0cf 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EdgeDescriptorDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EdgeDescriptorDisplayAdapter.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Iterator; import java.util.List; @@ -6,16 +6,21 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; -import com.gtnexus.appxpress.commons.NullSafeStringEntryImmutableMapBuilder; -import com.gtnexus.appxpress.platform.module.interpretation.workflow.WorkflowGraph; -import com.gtnexus.appxpress.platform.module.model.design.Transition; -import com.gtnexus.appxpress.platform.module.model.design.Workflow; +import com.gtnexus.pmm.app.platform.module.interpretation.workflow.WorkflowGraph; +import com.gtnexus.pmm.app.platform.module.model.design.Transition; +import com.gtnexus.pmm.app.platform.module.model.design.Workflow; public class EdgeDescriptorDisplayAdapter extends DisplayAdapter { - private static final Map DUMMY_DESC = new ImmutableMap.Builder().put("State", "") - .put("Edit Role", "").put("Action", "").put("To State", "").put("Action Roles", "") - .put("Precondition Fn", "").put("Post Transition Fn", "").build(); + private static final Map DUMMY_DESC = new ImmutableMap.Builder() + .put("State", "") + .put("Edit Role", "") + .put("Action", "") + .put("To State", "") + .put("Action Roles", "") + .put("Precondition Fn", "") + .put("Post Transition Fn", "") + .build(); public static List createDescriptors(Workflow wf) { return createDescriptors(WorkflowGraph.constructGraph(wf)); @@ -39,10 +44,15 @@ private static List descriptorsFor(WorkflowGraph.N ? Lists.newArrayList(new Transition()) : n.getTransitions(); for (Transition t : trans) { - Map desc = new NullSafeStringEntryImmutableMapBuilder().put("State", n.getState()) - .put("Edit Role", n.getEditRoles()).put("Action", t.getAction()).put("To State", t.getToState()) - .put("Action Roles", t.getRoles()).put("Precondition Fn", t.getPreconditionFn()) - .put("Post Transition Fn", t.getPostTransitionFn()).build(); + Map desc = new NullSafeStringEntryImmutableMapBuilder() + .put("State", n.getState()) + .put("Edit Role", n.getEditRoles()) + .put("Action", t.getAction()) + .put("To State", t.getToState()) + .put("Action Roles", t.getRoles()) + .put("Precondition Fn", t.getPreconditionFn()) + .put("Post Transition Fn", t.getPostTransitionFn()) + .build(); descs.add(new EdgeDescriptorDisplayAdapter(desc)); } return descs; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EmbeddedFieldsDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EmbeddedFieldsDisplayAdapter.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EmbeddedFieldsDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EmbeddedFieldsDisplayAdapter.java index 87b5077..3393f72 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EmbeddedFieldsDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EmbeddedFieldsDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.LinkField; +import com.gtnexus.pmm.app.platform.module.model.design.LinkField; public class EmbeddedFieldsDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EventsDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EventsDisplayAdapter.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EventsDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EventsDisplayAdapter.java index e2f47a5..4f5c41f 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/EventsDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/EventsDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.EventField; +import com.gtnexus.pmm.app.platform.module.model.design.EventField; public class EventsDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ExtensionPointDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ExtensionPointDisplayAdapter.java similarity index 94% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ExtensionPointDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ExtensionPointDisplayAdapter.java index f5d8245..4f1f9f0 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ExtensionPointDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ExtensionPointDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.CodExtensionPoint; +import com.gtnexus.pmm.app.platform.module.model.design.CodExtensionPoint; public class ExtensionPointDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IdentificationAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IdentificationAdapter.java similarity index 88% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IdentificationAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IdentificationAdapter.java index 912f12a..d64c635 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IdentificationAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IdentificationAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; public class IdentificationAdapter extends CustomObjectDesignV110DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IntegrationFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IntegrationFeatureDisplayAdapter.java similarity index 91% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IntegrationFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IntegrationFeatureDisplayAdapter.java index 8f54d8b..4bc22d5 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/IntegrationFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/IntegrationFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.IntegrationFeature; +import com.gtnexus.pmm.app.platform.module.model.design.IntegrationFeature; public class IntegrationFeatureDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NavFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NavFeatureDisplayAdapter.java similarity index 91% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NavFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NavFeatureDisplayAdapter.java index bd73aa7..014e478 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NavFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NavFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.NavFeature; +import com.gtnexus.pmm.app.platform.module.model.design.NavFeature; public class NavFeatureDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationConfigurationDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationConfigurationDisplayAdapter.java similarity index 95% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationConfigurationDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationConfigurationDisplayAdapter.java index ad0614e..2307622 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationConfigurationDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationConfigurationDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.platformmodule.NotificationConfiguration; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.NotificationConfiguration; public class NotificationConfigurationDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationTopicDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationTopicDisplayAdapter.java similarity index 84% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationTopicDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationTopicDisplayAdapter.java index e5d3409..6bc7617 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/NotificationTopicDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NotificationTopicDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.platformmodule.NotificationTopic; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.NotificationTopic; public class NotificationTopicDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/commons/NullSafeStringEntryImmutableMapBuilder.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NullSafeStringEntryImmutableMapBuilder.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/commons/NullSafeStringEntryImmutableMapBuilder.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NullSafeStringEntryImmutableMapBuilder.java index 99edf33..257d4e5 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/NullSafeStringEntryImmutableMapBuilder.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/NullSafeStringEntryImmutableMapBuilder.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.commons; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import java.util.Map.Entry; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PdfFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PdfFeatureDisplayAdapter.java similarity index 85% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PdfFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PdfFeatureDisplayAdapter.java index 08356c0..fe88f02 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PdfFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PdfFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.PdfFeature; +import com.gtnexus.pmm.app.platform.module.model.design.PdfFeature; public class PdfFeatureDisplayAdapter extends DisplayAdapter { private static final Function IS_ENABLED_FN = new BooleanDisplayFunction() { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PlatformModuleXmlDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PlatformModuleXmlDisplayAdapter.java similarity index 87% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PlatformModuleXmlDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PlatformModuleXmlDisplayAdapter.java index 9ab1c41..42df690 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PlatformModuleXmlDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PlatformModuleXmlDisplayAdapter.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.platformmodule.Metadata; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.Metadata; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; public class PlatformModuleXmlDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PrimitiveDisplayFunction.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PrimitiveDisplayFunction.java similarity index 86% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PrimitiveDisplayFunction.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PrimitiveDisplayFunction.java index 5a366a1..e604fac 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/PrimitiveDisplayFunction.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/PrimitiveDisplayFunction.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import com.google.common.base.Function; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ReportingFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ReportingFeatureDisplayAdapter.java similarity index 85% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ReportingFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ReportingFeatureDisplayAdapter.java index f107c90..cb2422b 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ReportingFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ReportingFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.ReportingFeature; +import com.gtnexus.pmm.app.platform.module.model.design.ReportingFeature; public class ReportingFeatureDisplayAdapter extends DisplayAdapter { private static final Function IS_ENABLED_FN = new PrimitiveDisplayFunction() { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RoleSecurityDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RoleSecurityDisplayAdapter.java similarity index 90% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RoleSecurityDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RoleSecurityDisplayAdapter.java index 5e92c71..6f13826 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RoleSecurityDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RoleSecurityDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.interpretation.role.security.NormalizedRoleSecurity; +import com.gtnexus.pmm.app.platform.module.interpretation.role.security.NormalizedRoleSecurity; public class RoleSecurityDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RuntimeSettingsAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RuntimeSettingsAdapter.java similarity index 90% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RuntimeSettingsAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RuntimeSettingsAdapter.java index 040f805..f748315 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/RuntimeSettingsAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/RuntimeSettingsAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; public class RuntimeSettingsAdapter extends CustomObjectDesignV110DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScalarFieldDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScalarFieldDisplayAdapter.java similarity index 95% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScalarFieldDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScalarFieldDisplayAdapter.java index 825ae25..c72da09 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScalarFieldDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScalarFieldDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.ScalarField; +import com.gtnexus.pmm.app.platform.module.model.design.ScalarField; public class ScalarFieldDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScriptingFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScriptingFeatureDisplayAdapter.java similarity index 88% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScriptingFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScriptingFeatureDisplayAdapter.java index 8efff4e..32fe32d 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/ScriptingFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/ScriptingFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.ScriptingFeature; +import com.gtnexus.pmm.app.platform.module.model.design.ScriptingFeature; public class ScriptingFeatureDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TemplateDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TemplateDisplayAdapter.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TemplateDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TemplateDisplayAdapter.java index 8b8422a..1b811ef 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TemplateDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TemplateDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.template.TemplateMediaV110; +import com.gtnexus.pmm.app.platform.module.model.template.TemplateMediaV110; public class TemplateDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TypeExtensionD1DisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TypeExtensionD1DisplayAdapter.java similarity index 91% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TypeExtensionD1DisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TypeExtensionD1DisplayAdapter.java index 52b0278..58eaff6 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/TypeExtensionD1DisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/TypeExtensionD1DisplayAdapter.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.typeextension.Callbacks; -import com.gtnexus.appxpress.platform.module.model.typeextension.TypeExtensionD1; +import com.gtnexus.pmm.app.platform.module.model.typeextension.Callbacks; +import com.gtnexus.pmm.app.platform.module.model.typeextension.TypeExtensionD1; public class TypeExtensionD1DisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/VersioningFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/VersioningFeatureDisplayAdapter.java similarity index 94% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/VersioningFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/VersioningFeatureDisplayAdapter.java index 078c58a..99c6706 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/VersioningFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/VersioningFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.VersioningFeature; +import com.gtnexus.pmm.app.platform.module.model.design.VersioningFeature; public class VersioningFeatureDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowDisplayAdapter.java similarity index 85% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowDisplayAdapter.java index b5fe4a9..aec1a18 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; -import com.gtnexus.appxpress.platform.module.model.design.Workflow; -import com.gtnexus.appxpress.platform.module.model.design.WorkflowFeature; +import com.gtnexus.pmm.app.platform.module.model.design.Workflow; +import com.gtnexus.pmm.app.platform.module.model.design.WorkflowFeature; public abstract class WorkflowDisplayAdapter extends DisplayAdapter { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowFeatureDisplayAdapter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowFeatureDisplayAdapter.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowFeatureDisplayAdapter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowFeatureDisplayAdapter.java index 2330079..2ec7743 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/adapter/WorkflowFeatureDisplayAdapter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/adapter/WorkflowFeatureDisplayAdapter.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.adapter; +package com.gtnexus.pmm.app.docgen.adapter; import java.util.Map; import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.design.WorkflowFeature; +import com.gtnexus.pmm.app.platform.module.model.design.WorkflowFeature; public class WorkflowFeatureDisplayAdapter extends WorkflowDisplayAdapter { diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/docgen/cli/DocumentGeneratorOptionInterpreter.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/cli/DocumentGeneratorOptionInterpreter.java new file mode 100644 index 0000000..7f9379d --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/cli/DocumentGeneratorOptionInterpreter.java @@ -0,0 +1,71 @@ +package com.gtnexus.pmm.app.docgen.cli; +//package com.gtnexus.pmm.pmdocgen.cli; +// +//import java.io.File; +//import java.nio.file.Path; +//import java.util.Arrays; +//import java.util.Collection; +// +//import com.gtnexus.pmm.AppXpressException; +//import com.gtnexus.pmm.api.v100.command.PMMCommandInfo; +//import com.gtnexus.pmm.cli.Select; +//import com.gtnexus.pmm.cli.option.ParsedOptions; +//import com.gtnexus.pmm.commons.CommandOptionInterpreter; +//import com.gtnexus.pmm.commons.CommandOptionInterpreterImpl; +//import com.gtnexus.pmm.commons.file.filter.FileFilterFactory; +//import com.gtnexus.pmm.commons.properties.PMProperties; +//import com.gtnexus.pmm.manager.AppXpressDirResolver; +//import com.gtnexus.pmm.pmdocgen.DocGenCommand; +// +//public class DocumentGeneratorOptionInterpreter extends CommandOptionInterpreterImpl +// implements CommandOptionInterpreter { +// +// private final AppXpressDirResolver resolver; +// private final Select selector; +// +// public DocumentGeneratorOptionInterpreter(PMMCommandInfo app, +// ParsedOptions parsedOptions, PMProperties properties, Select selector, +// AppXpressDirResolver resolver) { +// super(app, parsedOptions, properties); +// this.resolver = resolver; +// this.selector = selector; +// } +// +// @Override +// protected ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) +// throws AppXpressException { +// Path cwd = resolver.resovleCurrentDirectory(); +// if (parsedOpts.hasOption(DocGenCommand.selectOpt)) { +// doSelect(parsedOpts, cwd); +// } +// if (isCandidateForArgInjection(parsedOpts, cwd)) { +// parsedOpts.put(DocGenCommand.customerOpt, cwd); +// } +// return parsedOpts; +// } +// +// private boolean isCandidateForArgInjection(ParsedOptions parsedOpts, Path cwd) +// throws AppXpressException { +// return !parsedOpts.hasOption(DocGenCommand.customerOpt) +// && isCustomerFolder(cwd, DocGenCommand.localDirOpt); +// } +// +// private void doSelect(ParsedOptions parsedOpts, Path cwd) throws AppXpressException { +// if (!isCustomerFolder(cwd, DocGenCommand.localDirOpt)) { +// throw new AppXpressException("The select option must be run from a customer folder."); +// } +// Collection choices = getCandidates(cwd); +// if (choices.isEmpty()) { +// throw new AppXpressException("Nothing to select from!"); +// } +// File selection = selector.select(choices); +// parsedOpts.put(DocGenCommand.moduleOpt, selection); +// parsedOpts.put(DocGenCommand.customerOpt, cwd); +// } +// +// private Collection getCandidates(Path dir) { +// File[] files = dir.toFile().listFiles(FileFilterFactory.directoriesOnly()); +// return Arrays.asList(files); +// } +// +//} diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/BaseSheetRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/BaseSheetRenderer.java similarity index 83% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/BaseSheetRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/BaseSheetRenderer.java index 2994571..94bb88e 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/BaseSheetRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/BaseSheetRenderer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Iterator; @@ -6,11 +6,11 @@ import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.pmdocgen.adapter.DisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.style.GtnxStyleProviderImpl; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.style.StyleProvider; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.traversal.SheetTraverser; -import com.gtnexus.appxpress.pmdocgen.renderer.excel.traversal.SheetTraverserImpl; +import com.gtnexus.pmm.app.docgen.adapter.DisplayAdapter; +import com.gtnexus.pmm.app.docgen.renderer.excel.style.GtnxStyleProviderImpl; +import com.gtnexus.pmm.app.docgen.renderer.excel.style.StyleProvider; +import com.gtnexus.pmm.app.docgen.renderer.excel.traversal.SheetTraverser; +import com.gtnexus.pmm.app.docgen.renderer.excel.traversal.SheetTraverserImpl; public abstract class BaseSheetRenderer implements SheetRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/ChangeLogRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/ChangeLogRenderer.java similarity index 93% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/ChangeLogRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/ChangeLogRenderer.java index 57a6e18..230eab5 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/ChangeLogRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/ChangeLogRenderer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.List; import java.util.Map; @@ -11,8 +11,8 @@ import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; -import com.gtnexus.appxpress.pmdocgen.adapter.PlatformModuleXmlDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.PlatformModuleXmlDisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; public class ChangeLogRenderer extends BaseSheetRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomActionDocRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomActionDocRenderer.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomActionDocRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomActionDocRenderer.java index ce5bd77..17f209b 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomActionDocRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomActionDocRenderer.java @@ -1,9 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Collection; + import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.customaction.CustomActionD1; -import com.gtnexus.appxpress.pmdocgen.adapter.CustomActionD1DisplayAdapter; + +import com.gtnexus.pmm.app.docgen.adapter.CustomActionD1DisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.customaction.CustomActionD1; public class CustomActionDocRenderer extends BaseSheetRenderer> { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomLinkDocRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomLinkDocRenderer.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomLinkDocRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomLinkDocRenderer.java index ff3591f..f1fce62 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomLinkDocRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomLinkDocRenderer.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Collection; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.customlink.CustomLinkD1; -import com.gtnexus.appxpress.pmdocgen.adapter.CustomLinkD1DisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.CustomLinkD1DisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.customlink.CustomLinkD1; public class CustomLinkDocRenderer extends BaseSheetRenderer> { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomObjectDesignDocRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomObjectDesignDocRenderer.java similarity index 89% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomObjectDesignDocRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomObjectDesignDocRenderer.java index 5397b23..664896c 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/CustomObjectDesignDocRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/CustomObjectDesignDocRenderer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Arrays; import java.util.Collection; @@ -15,27 +15,27 @@ import com.google.common.base.Function; import com.google.common.collect.Collections2; -import com.gtnexus.appxpress.platform.module.interpretation.role.security.NormalizedRoleSecurity; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; -import com.gtnexus.appxpress.platform.module.model.design.WorkflowFeature; -import com.gtnexus.appxpress.pmdocgen.adapter.AttachmentFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.CustomObjectDesignV110DisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.DisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.EdgeDescriptorDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.EmbeddedFieldsDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.EventsDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.ExtensionPointDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.IdentificationAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.IntegrationFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.NavFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.PdfFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.ReportingFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.RoleSecurityDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.RuntimeSettingsAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.ScalarFieldDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.ScriptingFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.VersioningFeatureDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.WorkflowFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.AttachmentFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.CustomObjectDesignV110DisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.DisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.EdgeDescriptorDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.EmbeddedFieldsDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.EventsDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.ExtensionPointDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.IdentificationAdapter; +import com.gtnexus.pmm.app.docgen.adapter.IntegrationFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.NavFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.PdfFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.ReportingFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.RoleSecurityDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.RuntimeSettingsAdapter; +import com.gtnexus.pmm.app.docgen.adapter.ScalarFieldDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.ScriptingFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.VersioningFeatureDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.WorkflowFeatureDisplayAdapter; +import com.gtnexus.pmm.app.platform.module.interpretation.role.security.NormalizedRoleSecurity; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.design.WorkflowFeature; public class CustomObjectDesignDocRenderer extends BaseSheetRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/SheetRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/SheetRenderer.java similarity index 65% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/SheetRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/SheetRenderer.java index 7a0dca8..7664b39 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/SheetRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/SheetRenderer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; public interface SheetRenderer { public void render(X source); diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TemplatesRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TemplatesRenderer.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TemplatesRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TemplatesRenderer.java index 756786c..d523054 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TemplatesRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TemplatesRenderer.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Collection; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.template.TemplateMediaV110; -import com.gtnexus.appxpress.pmdocgen.adapter.TemplateDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.TemplateDisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.template.TemplateMediaV110; public class TemplatesRenderer extends BaseSheetRenderer> { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TopicsRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TopicsRenderer.java similarity index 75% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TopicsRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TopicsRenderer.java index 0144516..47a478f 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TopicsRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TopicsRenderer.java @@ -1,12 +1,12 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.platformmodule.NotificationConfiguration; -import com.gtnexus.appxpress.platform.module.model.platformmodule.NotificationTopic; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; -import com.gtnexus.appxpress.pmdocgen.adapter.NotificationConfigurationDisplayAdapter; -import com.gtnexus.appxpress.pmdocgen.adapter.NotificationTopicDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.NotificationConfigurationDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.NotificationTopicDisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.NotificationConfiguration; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.NotificationTopic; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; public class TopicsRenderer extends BaseSheetRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TypeExtensionDocRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TypeExtensionDocRenderer.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TypeExtensionDocRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TypeExtensionDocRenderer.java index 87339ff..69c6536 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/TypeExtensionDocRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/TypeExtensionDocRenderer.java @@ -1,9 +1,11 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import java.util.Collection; + import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.typeextension.TypeExtensionD1; -import com.gtnexus.appxpress.pmdocgen.adapter.TypeExtensionD1DisplayAdapter; + +import com.gtnexus.pmm.app.docgen.adapter.TypeExtensionD1DisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.typeextension.TypeExtensionD1; public class TypeExtensionDocRenderer extends BaseSheetRenderer> { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/UserInterfacesRenderer.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/UserInterfacesRenderer.java similarity index 78% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/UserInterfacesRenderer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/UserInterfacesRenderer.java index 8751e03..82033a7 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/UserInterfacesRenderer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/UserInterfacesRenderer.java @@ -1,10 +1,10 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel; +package com.gtnexus.pmm.app.docgen.renderer.excel; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import com.gtnexus.appxpress.platform.module.model.platformmodule.CustomUiConfiguration; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; -import com.gtnexus.appxpress.pmdocgen.adapter.CustomUiConfigurationDisplayAdapter; +import com.gtnexus.pmm.app.docgen.adapter.CustomUiConfigurationDisplayAdapter; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.CustomUiConfiguration; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; public class UserInterfacesRenderer extends BaseSheetRenderer { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxColors.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxColors.java similarity index 90% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxColors.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxColors.java index 3b1fc2b..bcef480 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxColors.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxColors.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.style; +package com.gtnexus.pmm.app.docgen.renderer.excel.style; import java.awt.Color; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxStyleProviderImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxStyleProviderImpl.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxStyleProviderImpl.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxStyleProviderImpl.java index 2d6cf32..45c192b 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/GtnxStyleProviderImpl.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/GtnxStyleProviderImpl.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.style; +package com.gtnexus.pmm.app.docgen.renderer.excel.style; import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.HorizontalAlignment; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/StyleProvider.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/StyleProvider.java similarity index 79% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/StyleProvider.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/StyleProvider.java index 9552428..305cbfa 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/style/StyleProvider.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/style/StyleProvider.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.style; +package com.gtnexus.pmm.app.docgen.renderer.excel.style; import org.apache.poi.xssf.usermodel.XSSFCellStyle; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/Coord.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/Coord.java similarity index 89% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/Coord.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/Coord.java index 24434b7..a78ea7d 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/Coord.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/Coord.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.traversal; +package com.gtnexus.pmm.app.docgen.renderer.excel.traversal; public class Coord { diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverser.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverser.java similarity index 80% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverser.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverser.java index f77185d..de3d3f9 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverser.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverser.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.traversal; +package com.gtnexus.pmm.app.docgen.renderer.excel.traversal; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverserImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverserImpl.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverserImpl.java rename to mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverserImpl.java index 3bc64cd..44c56bd 100644 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/renderer/excel/traversal/SheetTraverserImpl.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/docgen/renderer/excel/traversal/SheetTraverserImpl.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.pmdocgen.renderer.excel.traversal; +package com.gtnexus.pmm.app.docgen.renderer.excel.traversal; import java.util.Iterator; diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/extract/ExtractCommand.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/ExtractCommand.java new file mode 100644 index 0000000..b6cf398 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/ExtractCommand.java @@ -0,0 +1,80 @@ +package com.gtnexus.pmm.app.extract; + +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption.StandardOptions; +import com.gtnexus.pmm.api.v100.command.AbstractSubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.command.SubCommandMarker; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.common.CommandOptionCompleter; +import com.gtnexus.pmm.app.common.SubCommandHelpFormatter; +import com.gtnexus.pmm.app.extract.cli.ExtractorOption; +import com.gtnexus.pmm.app.extract.gitmap.GitMapper; + +@SubCommandMarker( + name = ExtractCommand.NAME, + description = "runs the platform module extractor tool. for more information please run pmm extract -h" +) +public class ExtractCommand extends AbstractSubCommand { + + public static final String NAME = "extract"; + + private final Set requiredOptions = new ImmutableSet.Builder() + .add(StandardOptions.LOCAL_DIR) + .add(StandardOptions.CUSTOMER) + .add(StandardOptions.MODULE) + .add(ExtractorOption.PLATFORM_ZIP) + .build(); + + private final Set options = new ImmutableSet.Builder() + .addAll(requiredOptions) + .add(StandardOptions.HELP) + .add(ExtractorOption.OVERWRITE_FEF) + .add(ExtractorOption.OVERWRITE_SCRIPTS) + .build(); + + private final Map defaults = new ImmutableMap.Builder() + .put(ExtractorOption.OVERWRITE_FEF, "Y") + .put(ExtractorOption.OVERWRITE_SCRIPTS, "Y") + .build(); + + private final CommandOptionCompleter optionsCompleter; + + public ExtractCommand(PlatformModuleManagerServices services, String... args) { + super(services, args); + this.optionsCompleter = new CommandOptionCompleter(services, requiredOptions, defaults); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public Set getOptions() { + return options; + } + + @Override + public void execute() throws SubCommandException { + Map optionsMap = this.parse(); + if(optionsMap.containsKey(StandardOptions.HELP)) { + new SubCommandHelpFormatter(this).displayHelp(); + return; + } + optionsMap = optionsCompleter.complete(optionsMap); + GitMapper tool = GitMapper.createMapper(this.getServices(), optionsMap); + try { + tool.doMapping(); + System.out.println("Success!"); + } catch (SubCommandException e) { + throw new SubCommandException("Failure when running pmextractor.", e); + } + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOption.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOption.java new file mode 100644 index 0000000..067a176 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOption.java @@ -0,0 +1,87 @@ +package com.gtnexus.pmm.app.extract.cli; + +import java.util.EnumSet; +import java.util.Set; + +import com.google.common.collect.ImmutableSet; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +/** + * Enumeration of options that can be stored in the Properties file or read in + * from the CLI. + */ +public enum ExtractorOption implements CommandOption { + + HELP("h", "help", String.class, "Display usage for this tool", false, false, null), + PLATFORM_ZIP("pz", "platformZip", String.class, "Exported Platform Module Name", true, true, null), + LOCAL_DIR("ld", "localDir", String.class, "Relative Path of GIT staging folder", true, true, null), + CUSTOMER("c", "customer", String.class, "Customer of Platform Module", true, true, null), + SELECT("s", "select", Integer.class, "Select platform from the folders present in the cwd.", false, false, null), + MODULE("m", "module", String.class, "Platform Module that is being exported", true, true, null), + OVERWRITE_SCRIPTS("os", "overwriteScripts", Boolean.class, "If Y -> overwriteScripts = true", true, false, "Y"), + OVERWRITE_FEF("of", "overwriteFef", Boolean.class, "If Y -> overwriteFEF = true", true, false, "Y"); + + private final String flag; + private final String longName; + private final Class type; + private final boolean hasArg; + private final String description; + + private final static Set allOptions = new ImmutableSet.Builder() + .addAll(EnumSet.allOf(ExtractorOption.class)) + .build(); + + /** + * + * @param longName + * The name of this ExtractorOption. + * @param type + * The ExtractorOption type. + * @param description + * @param isMandatory + * @param defaulValue + */ + private ExtractorOption(String flag, String longName, Class type, String description, boolean hasArg, + boolean isMandatory, String defaulValue) { + this.flag = flag; + this.longName = longName; + this.type = type; + this.hasArg = hasArg; + this.description = description; + } + + @Override + public String toString() { + return longName; + } + + @Override + public String getLongName() { + return longName; + } + + @Override + public Class getType() { + return type; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public boolean hasArg() { + return hasArg; + } + + @Override + public String getFlag() { + return flag; + } + + public static Set getAllOptions() { + return allOptions; + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOptionInterpreter.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOptionInterpreter.java new file mode 100644 index 0000000..90959fb --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/cli/ExtractorOptionInterpreter.java @@ -0,0 +1,63 @@ +package com.gtnexus.pmm.app.extract.cli; +//package com.gtnexus.pmm.pmextractor.cli; +// +//import static com.gtnexus.pmm.AppXpressConstants.ZIP_EXTENSION; +// +//import java.io.File; +//import java.nio.file.Path; +//import java.util.Arrays; +//import java.util.Collection; +// +//import com.gtnexus.pmm.AppXpressException; +//import com.gtnexus.pmm.api.v100.command.PMMCommandInfo; +//import com.gtnexus.pmm.cli.Select; +//import com.gtnexus.pmm.cli.option.ParsedOptions; +//import com.gtnexus.pmm.commons.CommandOptionInterpreter; +//import com.gtnexus.pmm.commons.CommandOptionInterpreterImpl; +//import com.gtnexus.pmm.commons.file.filter.FileFilterFactory; +//import com.gtnexus.pmm.commons.properties.PMProperties; +//import com.gtnexus.pmm.manager.AppXpressDirResolver; +//import com.gtnexus.pmm.pmextractor.exception.PMExtractorException; +// +//public class ExtractorOptionInterpreter extends CommandOptionInterpreterImpl +// implements CommandOptionInterpreter { +// +// private final Select selector; +// private AppXpressDirResolver resolver; +// +// public ExtractorOptionInterpreter(PMMCommandInfo app, +// ParsedOptions parsedOptions, PMProperties properties, Select selector, +// AppXpressDirResolver resolver) { +// super(app, parsedOptions, properties); +// this.selector = selector; +// this.resolver = resolver; +// } +// +// @Override +// public ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) +// throws AppXpressException { +// Path cwd = resolver.resovleCurrentDirectory(); +// if (parsedOpts.hasOption(ExtractorOption.SELECT)) { +// Collection choices = getCandidates(cwd); +// if (choices.isEmpty()) { +// throw new PMExtractorException("There are no .zip's to select from!"); +// } +// File selection = selector.select(choices); +// parsedOpts.put(ExtractorOption.PLATFORM_ZIP, selection); +// } +// if (isCandidateForArgInjection(parsedOpts, cwd)) { +// parsedOpts.put(ExtractorOption.CUSTOMER, cwd); +// } +// return parsedOpts; +// } +// +// private boolean isCandidateForArgInjection(ParsedOptions parsedOpts, Path cwd) +// throws AppXpressException { +// return !parsedOpts.hasOption(ExtractorOption.CUSTOMER) && isCustomerFolder(cwd, ExtractorOption.LOCAL_DIR); +// } +// +// private Collection getCandidates(Path dir) { +// File[] files = dir.toFile().listFiles(FileFilterFactory.endsWith(ZIP_EXTENSION)); +// return Arrays.asList(files); +// } +//} diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/exception/PMExtractorException.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/exception/PMExtractorException.java similarity index 66% rename from src/main/java/com/gtnexus/appxpress/pmextractor/exception/PMExtractorException.java rename to mapp/src/main/java/com/gtnexus/pmm/app/extract/exception/PMExtractorException.java index 8eb9148..ac04538 100644 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/exception/PMExtractorException.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/exception/PMExtractorException.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.pmextractor.exception; +package com.gtnexus.pmm.app.extract.exception; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; /** * Created by jjdonov on 9/29/14. */ -public class PMExtractorException extends AppXpressException { +public class PMExtractorException extends SubCommandException { private static final long serialVersionUID = 5468857470158908903L; diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapPrep.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapPrep.java similarity index 70% rename from src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapPrep.java rename to mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapPrep.java index 26f1c29..2f63aa4 100644 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapPrep.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapPrep.java @@ -1,24 +1,19 @@ -package com.gtnexus.appxpress.pmextractor.gitmap; +package com.gtnexus.pmm.app.extract.gitmap; -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.BACKUP_FLDR; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_LINK_D1; -import static com.gtnexus.appxpress.AppXpressConstants.UI_BUNDLE_PREFIX; +import static com.gtnexus.pmm.app.AppXpressConstants.$; +import static com.gtnexus.pmm.app.AppXpressConstants.BACKUP_FLDR; +import static com.gtnexus.pmm.app.AppXpressConstants.CUSTOM_LINK_D1; +import static com.gtnexus.pmm.app.AppXpressConstants.UI_BUNDLE_PREFIX; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import com.gtnexus.appxpress.AppXpressConstants; -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.commons.HasPrerequisite; -import com.gtnexus.appxpress.commons.Preparation; -import com.gtnexus.appxpress.commons.ZipService; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.context.TempResourceHolder; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.AppXpressConstants; +import com.gtnexus.pmm.app.build.exception.PMBuilderException; /** * Performs all prep work for GitMap, including cleaning directories, unzipping @@ -27,21 +22,16 @@ * @author jdonovan * */ -public class GitMapPrep implements HasPrerequisite, Preparation { +public class GitMapPrep { - private final FileService fs; - private final ZipService zs; - private final TempResourceHolder tmp; + private final PlatformModuleManagerServices services; - public GitMapPrep(TempResourceHolder tmp) { - this.fs = new FileService(); - this.zs = new ZipService(AppXpressConstants.IGNORE_SET); - this.tmp = tmp; + public GitMapPrep(PlatformModuleManagerServices services) { + this.services = services; } - @Override public void prepare(GitMapVO vo) throws PMBuilderException { - if (!isMet(vo)) { + if (!preconditionsMet(vo)) { throw new PMBuilderException("Precondition failed."); } cleanup(vo.getUnzipDir()); @@ -54,7 +44,7 @@ public void prepare(GitMapVO vo) throws PMBuilderException { private void cleanup(File unzipDestination) throws PMBuilderException { if (unzipDestination.exists()) { try { - fs.emptyDir(unzipDestination); + this.services.getFileService().emptyDir(unzipDestination); } catch (IOException e) { throw new PMBuilderException("Exception when cleaning unzipDestination", e); } @@ -78,9 +68,9 @@ private void clearCustomLinksXML(File customerPath) throws PMBuilderException { private void unzipPlatformZip(File platformZip, File unzipDestination) throws PMBuilderException { if (platformZip.exists()) { try { - zs.unzip(platformZip, unzipDestination, true); - tmp.deleteOnExit(unzipDestination); - } catch (AppXpressException e) { + this.services.getZipService().unzip(platformZip, unzipDestination, true); + this.services.getTemporaryResourceService().markForDeletion(unzipDestination); + } catch (SubCommandException e) { throw new PMBuilderException("Exception when unzipping platformZip: " + platformZip, e); } } else { @@ -108,10 +98,10 @@ private void makeHumanReadable(File f) throws PMBuilderException { } try { if (f.getName().contains($)) { - fs.renameFile(f, f.getName().replace($, "")); + this.services.getFileService().renameFile(f, f.getName().replace($, "")); } if (parentIsCustomUi(f) && customUiBundleHasPrefix(f)) { - fs.renameFile(f, f.getName().substring(2)); + this.services.getFileService().renameFile(f, f.getName().substring(2)); } } catch (IOException e) { throw new PMBuilderException("Exception when coercing module to human readable format ->" + f, e); @@ -133,7 +123,7 @@ private void checkIfBundle(File f) throws PMBuilderException { int terminal = fName.length() - "Bundle".length(); fName = fName.substring(0, terminal); try { - fs.renameFile(f, fName); + this.services.getFileService().renameFile(f, fName); } catch (IOException e) { throw new PMBuilderException("Failed to rename bundle " + fName, e); } @@ -144,20 +134,19 @@ private void checkIfBundle(File f) throws PMBuilderException { * Backs up folder/customer/cust/plat into a folder called PM_Git_Backup */ private void backup(Path customerPath, String platform) { - AppXpressDirResolver resolver = new AppXpressDirResolver(); - Path bkpPath = resolver.resolveAppXpressDir().resolve(BACKUP_FLDR).resolve(platform); + Path appXDir = this.services.getEnvironmentService().getAppXDir(); + Path bkpPath = appXDir.resolve(BACKUP_FLDR).resolve(platform); try { if (Files.exists(bkpPath)) { - fs.emptyDir(bkpPath); + this.services.getFileService().emptyDir(bkpPath); } - fs.copyDirectory(customerPath, bkpPath); + this.services.getFileService().copyDirectory(customerPath, bkpPath); } catch (IOException e) { System.err.println("error backing up -> " + e); } } - @Override - public boolean isMet(GitMapVO vo) { + public boolean preconditionsMet(GitMapVO vo) { if (!validateAndEnsurePathExists(vo)) { System.err.println("ERROR: Paths are not set up properly!"); return false; diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVO.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVO.java similarity index 69% rename from src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVO.java rename to mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVO.java index a811257..5609256 100644 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVO.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVO.java @@ -1,11 +1,13 @@ -package com.gtnexus.appxpress.pmextractor.gitmap; +package com.gtnexus.pmm.app.extract.gitmap; -import static com.gtnexus.appxpress.AppXpressConstants.PLATFORM_MODULE_UNZIP_NAME; +import static com.gtnexus.pmm.app.AppXpressConstants.PLATFORM_MODULE_UNZIP_NAME; import java.io.File; import java.util.Map; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption.StandardOptions; +import com.gtnexus.pmm.app.extract.cli.ExtractorOption; public class GitMapVO { @@ -19,10 +21,10 @@ public class GitMapVO { private final boolean overwriteScripts; private final boolean overwriteFef; - public GitMapVO(Map optionMap) { - this.localDir = new File(optionMap.get(ExtractorOption.LOCAL_DIR)); - this.customer = optionMap.get(ExtractorOption.CUSTOMER); - this.platform = optionMap.get(ExtractorOption.MODULE); + public GitMapVO(Map optionMap) { + this.localDir = new File(optionMap.get(StandardOptions.LOCAL_DIR)); + this.customer = optionMap.get(StandardOptions.CUSTOMER); + this.platform = optionMap.get(StandardOptions.MODULE); this.customerDir = localDir.toPath().resolve(customer).toFile(); this.platformDir = customerDir.toPath().resolve(platform).toFile(); this.platformZip = new File(optionMap.get(ExtractorOption.PLATFORM_ZIP)); diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVisitor.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVisitor.java similarity index 81% rename from src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVisitor.java rename to mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVisitor.java index 064ebf3..9d3fd64 100644 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapVisitor.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapVisitor.java @@ -1,8 +1,8 @@ -package com.gtnexus.appxpress.pmextractor.gitmap; +package com.gtnexus.pmm.app.extract.gitmap; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_UI; -import static com.gtnexus.appxpress.AppXpressConstants.IGNORE_SET; -import static com.gtnexus.appxpress.AppXpressConstants.JS_EXTENSION; +import static com.gtnexus.pmm.app.AppXpressConstants.CUSTOM_UI; +import static com.gtnexus.pmm.app.AppXpressConstants.IGNORE_SET; +import static com.gtnexus.pmm.app.AppXpressConstants.JS_EXTENSION; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -12,7 +12,7 @@ import java.util.LinkedList; import java.util.List; -import com.gtnexus.appxpress.commons.file.CopyDirVisitor; +import com.gtnexus.pmm.app.common.file.CopyDirVisitor; public class GitMapVisitor extends CopyDirVisitor { diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapper.java b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapper.java similarity index 66% rename from src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapper.java rename to mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapper.java index fff577f..8d7031b 100644 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/gitmap/GitMapper.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/extract/gitmap/GitMapper.java @@ -1,12 +1,12 @@ -package com.gtnexus.appxpress.pmextractor.gitmap; +package com.gtnexus.pmm.app.extract.gitmap; -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_OBJECT_MODULE; -import static com.gtnexus.appxpress.AppXpressConstants.DESIGNS; -import static com.gtnexus.appxpress.AppXpressConstants.JS_EXTENSION; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTS; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; +import static com.gtnexus.pmm.app.AppXpressConstants.$; +import static com.gtnexus.pmm.app.AppXpressConstants.CUSTOM_OBJECT_MODULE; +import static com.gtnexus.pmm.app.AppXpressConstants.DESIGNS; +import static com.gtnexus.pmm.app.AppXpressConstants.JS_EXTENSION; +import static com.gtnexus.pmm.app.AppXpressConstants.SCRIPTS; +import static com.gtnexus.pmm.app.AppXpressConstants.SCRIPT_DESIGN; +import static com.gtnexus.pmm.app.AppXpressConstants.ZIP_EXTENSION; import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; import java.io.File; @@ -17,13 +17,13 @@ import java.util.List; import java.util.Map; -import com.gtnexus.appxpress.commons.Mapper; -import com.gtnexus.appxpress.commons.Preparation; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; -import com.gtnexus.appxpress.pmextractor.exception.PMExtractorException; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.extract.cli.ExtractorOption; +import com.gtnexus.pmm.app.extract.exception.PMExtractorException; +import com.gtnexus.pmm.app.service.FileServiceImpl; /** * Relies on Preparation, then takes extracted platform and maps it to the @@ -35,16 +35,14 @@ * @version 1.0 * @date 8-27-2014 GT Nexus */ -public class GitMapper implements Mapper { +public class GitMapper { - private final AppXpressContext ctx; private final GitMapVO vo; private List overwrittenScripts; - private final Preparation prep; + private final GitMapPrep prep; private final FileService fs; - public static GitMapper createMapper(AppXpressContext context) { - Map optionMap = context.getOptMap(); + public static GitMapper createMapper(PlatformModuleManagerServices services, Map optionMap) { if (optionMap.containsKey(ExtractorOption.PLATFORM_ZIP)) { String platformZip = optionMap.get(ExtractorOption.PLATFORM_ZIP); if (!platformZip.endsWith(ZIP_EXTENSION)) { @@ -52,22 +50,20 @@ public static GitMapper createMapper(AppXpressContext context) optionMap.put(ExtractorOption.PLATFORM_ZIP, platformZip); } } - return new GitMapper(context); + return new GitMapper(services, optionMap); } - public GitMapper(AppXpressContext context) { - this.ctx = context; - this.vo = new GitMapVO(context.getOptMap()); + public GitMapper(PlatformModuleManagerServices services, Map optionMap) { + this.vo = new GitMapVO(optionMap); this.overwrittenScripts = new ArrayList<>(); - this.prep = new GitMapPrep(ctx); - this.fs = new FileService(); + this.prep = new GitMapPrep(services); + this.fs = new FileServiceImpl(); } /** * Performs the appropriate actions for module extraction */ - @Override - public void doMapping() throws AppXpressException { + public void doMapping() throws SubCommandException { try { prep.prepare(vo); mapCustomObjectDesign(); @@ -75,8 +71,8 @@ public void doMapping() throws AppXpressException { if (vo.isOverwriteScripts() && overwrittenScripts.size() > 0) { printOverwrittenScripts(); } - } catch (AppXpressException e) { - throw new AppXpressException("Exception when performing mapping!", e); + } catch (SubCommandException e) { + throw new SubCommandException("Exception when performing mapping!", e); } } @@ -106,9 +102,9 @@ private void mapFolders(File exportedPlatform, File destinationPlatform) throws * * @param path * Path of Unzipped Exported platform module - * @throws AppXpressException + * @throws SubCommandException */ - private void mapCustomObjectDesign() throws AppXpressException { + private void mapCustomObjectDesign() throws SubCommandException { Path scriptsPath = vo.getUnzipDir().toPath().resolve(CUSTOM_OBJECT_MODULE).resolve(DESIGNS).resolve(SCRIPTS); if (!Files.exists(scriptsPath)) { System.out.println("Cannot find script folder: " + scriptsPath.toString()); @@ -121,7 +117,7 @@ private void mapCustomObjectDesign() throws AppXpressException { try { fs.renameFile(co, co.getName().replace(SCRIPT_DESIGN + $, "")); } catch (IOException e) { - throw new AppXpressException("Exception when renaming script!", e); + throw new SubCommandException("Exception when renaming script!", e); } } else { String dirName = co.getName().replace(SCRIPT_DESIGN + $, "").replace(JS_EXTENSION, ""); diff --git a/src/main/java/com/gtnexus/appxpress/AppXpressDirResolver.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/AppXpressDirResolver.java similarity index 83% rename from src/main/java/com/gtnexus/appxpress/AppXpressDirResolver.java rename to mapp/src/main/java/com/gtnexus/pmm/app/manager/AppXpressDirResolver.java index f059cd7..315b365 100644 --- a/src/main/java/com/gtnexus/appxpress/AppXpressDirResolver.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/AppXpressDirResolver.java @@ -1,6 +1,6 @@ -package com.gtnexus.appxpress; +package com.gtnexus.pmm.app.manager; -import static com.gtnexus.appxpress.AppXpressConstants.DIR_TEMPLATE; +import static com.gtnexus.pmm.app.AppXpressConstants.DIR_TEMPLATE; import java.io.File; import java.nio.file.Path; diff --git a/src/main/java/com/gtnexus/appxpress/commons/DirectoryHelper.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/DirectoryHelper.java similarity index 67% rename from src/main/java/com/gtnexus/appxpress/commons/DirectoryHelper.java rename to mapp/src/main/java/com/gtnexus/pmm/app/manager/DirectoryHelper.java index 82fae85..deedfa9 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/DirectoryHelper.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/DirectoryHelper.java @@ -1,14 +1,13 @@ -package com.gtnexus.appxpress.commons; +package com.gtnexus.pmm.app.manager; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Properties; -import com.gtnexus.appxpress.AppXpressConstants; -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.AppXpressConstants; +import com.gtnexus.pmm.app.common.PMProperties; /** * Helper class used by pmm. Ensures the existence of necessary directories and @@ -41,32 +40,32 @@ private String getPropertiesFilePath() { /** * Ensures AppXPress Directories and associated files exist on the system. * - * @throws AppXpressException + * @throws SubCommandException */ - public void ensureAppXpress() throws AppXpressException { + public void ensureAppXpress() throws SubCommandException { ensureAppXPressDirectoryExists(); pmbProperties = getAndEnsurePropertiesExist(); } /** - * @throws AppXpressException + * @throws SubCommandException * if the AppXpress directory does not exist and cannot be created. */ - private void ensureAppXPressDirectoryExists() throws AppXpressException { + private void ensureAppXPressDirectoryExists() throws SubCommandException { File appXpressDirectory = resolver.resolveAppXpressDir().toFile(); if (!appXpressDirectory.isDirectory() && !appXpressDirectory.mkdirs()) { - throw new AppXpressException("WARNING: AppXpress directory could not be found" + throw new SubCommandException("WARNING: AppXpress directory could not be found" + "and could not be created: " + appXpressDirectory.getAbsolutePath()); } } /** * @return the properties file if one exists, else a newly created one. - * @throws AppXpressException + * @throws SubCommandException * if the properties file does not exist and a new one cannot be * created. */ - private PMProperties getAndEnsurePropertiesExist() throws AppXpressException { + private PMProperties getAndEnsurePropertiesExist() throws SubCommandException { File propertiesFile = new File(getPropertiesFilePath()); if (!propertiesFile.exists()) { return makePropertiesFile(propertiesFile); @@ -75,21 +74,21 @@ private PMProperties getAndEnsurePropertiesExist() throws AppXpressException { } } - private PMProperties makePropertiesFile(File propertiesFile) throws AppXpressException { + private PMProperties makePropertiesFile(File propertiesFile) throws SubCommandException { try { propertiesFile.createNewFile(); } catch (IOException e) { - throw new AppXpressException("WARNING: Settings file couldn't be created: " + getPropertiesFilePath(), e); + throw new SubCommandException("WARNING: Settings file couldn't be created: " + getPropertiesFilePath(), e); } return new PMProperties(new Properties(), propertiesFile); } - private PMProperties readProperties(File propertiesFile) throws AppXpressException { + private PMProperties readProperties(File propertiesFile) throws SubCommandException { Properties properties = new Properties(); try (FileInputStream propInputStream = new FileInputStream(propertiesFile)) { properties.load(propInputStream); } catch (IOException e) { - throw new AppXpressException("Exception while loading properties file.", e); + throw new SubCommandException("Exception while loading properties file.", e); } return new PMProperties(properties, propertiesFile); } @@ -97,11 +96,11 @@ private PMProperties readProperties(File propertiesFile) throws AppXpressExcepti /** * * @return the properties file - * @throws AppXpressException + * @throws SubCommandException */ - public PMProperties getPmProperties() throws AppXpressException { + public PMProperties getPmProperties() throws SubCommandException { if (pmbProperties == null) { - throw new AppXpressException("ensureAppXpress() must be called before getPmbProperties"); + throw new SubCommandException("ensureAppXpress() must be called before getPmbProperties"); } return pmbProperties; } diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/manager/Help.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/Help.java new file mode 100644 index 0000000..df191dc --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/Help.java @@ -0,0 +1,83 @@ +package com.gtnexus.pmm.app.manager; + +import java.util.Set; +import java.util.regex.Pattern; + +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.collect.Iterables; +import com.gtnexus.pmm.api.v100.command.AbstractSubCommand; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.manager.command.CLICommand; + +public class Help implements CLICommand { + + private final Set commands; + + public Help(Set commands) { + this.commands = commands; + } + + @Override + public String getName() { + return "help"; + } + + @Override + public String getDescription() { + return "display this message"; + } + + @Override + public String getFlag() { + return "h"; + } + + @Override + public AbstractSubCommand constructCommand(final PlatformModuleManagerServices services, final String... args) { + return new AbstractSubCommand(services, args) { + + private final String name = "help"; + private final String usage = Joiner.on("\n") + .join(Iterables.transform(commands, new Function() { + @Override + public String apply(CLICommand cmd) { + StringBuilder b = new StringBuilder(); + b.append(cmd.getName()); + if (cmd.getFlag() != null && !cmd.getFlag().isEmpty()) { + b.append(" (-").append(cmd.getFlag()).append(")"); + } else { + b.append("\t"); + } + b.append("\t").append(cmd.getDescription()); + return b.toString(); + } + })); + private final String unrecognizedMsg = "Unrecognized command %s. See pmm help."; + private final String helpMsg = "Welcome to the AppXpress Platform Module Manager\n\n%s"; + + private Pattern p = Pattern.compile("^(-h|(--)?hello)"); + + @Override + public String getName() { + return name; + } + + @Override + public void execute() { + String identifier = args.length > 0 ? args[0] : null; + if(identifier == null || p.matcher(identifier).matches()) { + printHelp(helpMsg, usage); + } else { + printHelp(unrecognizedMsg, identifier); + } + } + + private void printHelp(String template, String ...args) { + System.out.println(String.format(template, (Object[])args)); + } + + }; + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/manager/SubCommandScanner.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/SubCommandScanner.java new file mode 100644 index 0000000..53cf31b --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/SubCommandScanner.java @@ -0,0 +1,140 @@ +package com.gtnexus.pmm.app.manager; + +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.DirectoryStream; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.PathMatcher; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import org.reflections.Reflections; +import org.reflections.util.ConfigurationBuilder; + +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; +import com.google.common.collect.Sets.SetView; +import com.gtnexus.pmm.api.v100.command.AbstractSubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommandMarker; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.app.build.BuildCommand; +import com.gtnexus.pmm.app.docgen.DocGenCommand; +import com.gtnexus.pmm.app.extract.ExtractCommand; +import com.gtnexus.pmm.app.manager.command.CLICommand; + +@SuppressWarnings("unchecked") +public class SubCommandScanner { + + private static final String PLUGIN_PKG = "com.gtnexus.pmm.plugin"; + private static boolean scanForPlugins = true; + private static Set> coreSubCommands = new ImmutableSet.Builder>() + .add(BuildCommand.class) + .add(ExtractCommand.class) + .add(DocGenCommand.class) + .build(); + + public static Set scan() { + Set commands = new HashSet<>(); + commands.addAll(scanForCoreCommands()); + if(scanForPlugins) { + commands.addAll(scanForPluginCommands()); + } + return commands; + } + + private static Set scanForCoreCommands() { + Set commands = new HashSet<>(); + for(Class type : coreSubCommands) { + SubCommandMarker marker = type.getAnnotation(SubCommandMarker.class); + CLICommand wrap = CLICommand.Helper.wrap(marker, getConstructor(type, marker)); + commands.add(wrap); + } + return commands; + } + + private static Set scanForPluginCommands() { + URL[] pluginUrls = getPluginUrls(); + if(pluginUrls.length == 0) { + return Collections.emptySet(); + } + return scanUrls(pluginUrls); + } + + private static Set scanUrls(URL[] pluginUrls) { + Set commands = new HashSet<>(); + ConfigurationBuilder b = createConfiguration(pluginUrls); + Reflections reflections = new Reflections(b); + Set> typesAnnotatedWith = reflections.getTypesAnnotatedWith(SubCommandMarker.class); + Set> subTypesOf = reflections.getSubTypesOf(AbstractSubCommand.class); + SetView> intersection = Sets.intersection(typesAnnotatedWith, subTypesOf); + for (Class type : intersection) { + SubCommandMarker marker = type.getAnnotation(SubCommandMarker.class); + CLICommand wrap = CLICommand.Helper.wrap(marker, getConstructor(type, marker)); + commands.add(wrap); + } + return commands; + } + + private static ConfigurationBuilder createConfiguration(URL[] pluginUrls) { + URLClassLoader classLoader = new URLClassLoader(pluginUrls); + ConfigurationBuilder b = new ConfigurationBuilder() + .addClassLoader(classLoader) + .addUrls(pluginUrls) + .forPackages(PLUGIN_PKG); + return b; + } + + static PathMatcher pm = FileSystems.getDefault().getPathMatcher("glob:**.jar"); + + static DirectoryStream.Filter pf = new DirectoryStream.Filter() { + + @Override + public boolean accept(Path entry) throws IOException { + boolean matches = pm.matches(entry); + return matches; + } + + }; + + + private static URL[] getPluginUrls() { + Set urlSet = new HashSet<>(); + String preamble = "Exception during start up. "; + String notExistsTemplate = preamble + "PlugIn path %s does not exist"; + String notADirTemplate = preamble + "Plugin path %s is not a directory"; + Path pluginPath = Paths.get("/code/gtnexus/appx/pmm-upload/build/libs/"); + if(!Files.exists(pluginPath)) { + throw new RuntimeException(String.format(notExistsTemplate, pluginPath.toAbsolutePath().toString())); + } else if(!Files.isDirectory(pluginPath)) { + throw new RuntimeException(String.format(notADirTemplate, pluginPath.toAbsolutePath().toString())); + } + try(DirectoryStream pluginDirectoryStream = Files.newDirectoryStream(pluginPath, pf)) { + for(Path p : pluginDirectoryStream) { + urlSet.add(p.toUri().toURL()); + } + } catch(IOException e) { + throw new RuntimeException(preamble, e); + } + return urlSet.toArray(new URL[urlSet.size()]); + } + + private static Constructor getConstructor(Class type, SubCommandMarker marker) { + Constructor constructor; + try { + constructor = (Constructor) type + .getConstructor(PlatformModuleManagerServices.class, String[].class); + } catch (NoSuchMethodException e) { + throw new RuntimeException(marker.name() + " is missing a constructor.", e); + } catch (SecurityException e) { + throw new RuntimeException( + "Failure during startup. Access to " + marker.name() + "'s constructor was denied", e); + } + return constructor; + } +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CLICommand.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CLICommand.java new file mode 100644 index 0000000..9a6e2ce --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CLICommand.java @@ -0,0 +1,55 @@ +package com.gtnexus.pmm.app.manager.command; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +import com.gtnexus.pmm.api.v100.command.AbstractSubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommand; +import com.gtnexus.pmm.api.v100.command.SubCommandMarker; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; + +public interface CLICommand { + + public String getName(); + + public String getDescription(); + + public String getFlag(); + + public SubCommand constructCommand(PlatformModuleManagerServices services, String... args); + + public static class Helper { + + public static CLICommand wrap(final SubCommandMarker marker, final Constructor constructor) { + return new CLICommand() { + + @Override + public String getName() { + return marker.name(); + } + + @Override + public String getFlag() { + return marker.flag(); + } + + @Override + public String getDescription() { + return marker.description(); + } + + @Override + public SubCommand constructCommand(PlatformModuleManagerServices services, String... args) { + try { + return constructor.newInstance(services, args); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new RuntimeException(e); + } + } + }; + } + } +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CommandIdentifier.java b/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CommandIdentifier.java new file mode 100644 index 0000000..4a44ec1 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/manager/command/CommandIdentifier.java @@ -0,0 +1,44 @@ +package com.gtnexus.pmm.app.manager.command; + +import java.util.Set; + +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; + +public class CommandIdentifier { + + private final Set commands; + + public CommandIdentifier(Set commands) { + Preconditions.checkNotNull(commands); + Preconditions.checkArgument(commands.size() > 0); + this.commands = commands; + } + + public Optional identify(String cmdNameOrFlag) { + if (cmdNameOrFlag == null || cmdNameOrFlag.isEmpty()) { + return Optional.absent(); + } + for (CLICommand command : commands) { + if (isNameOrFlagMatch(command, cmdNameOrFlag)) { + return Optional.fromNullable(command); + } + } + return Optional.absent(); + } + + private boolean isNameOrFlagMatch(CLICommand command, String cmd) { + if (command.getName().equals(cmd)) { + return true; + } + if (command.getFlag() != null && cmd.startsWith("-")) { + if (command.getFlag().equals(cmd.substring(1, cmd.length()))) { + return true; + } + } + return false; + } + + + +} diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/ModuleModelPointer.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleModelPointer.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/ModuleModelPointer.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleModelPointer.java index d03c579..496c2df 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/ModuleModelPointer.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleModelPointer.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.platform.module; +package com.gtnexus.pmm.app.platform.module; import java.io.File; import java.util.Arrays; diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModulePointer.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModulePointer.java new file mode 100644 index 0000000..f6f5fc0 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModulePointer.java @@ -0,0 +1,44 @@ +package com.gtnexus.pmm.app.platform.module; + +import java.io.File; +import java.util.Map; + +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption.StandardOptions; +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +public class ModulePointer { + + private final File localDir; + private final File targetModule; + + public static ModulePointer make(Map optMap) throws SubCommandException { + File localDir = new File(optMap.get(StandardOptions.LOCAL_DIR)); + File target = localDir.toPath().resolve(optMap.get(StandardOptions.CUSTOMER)) + .resolve(optMap.get(StandardOptions.MODULE)).toFile(); + if (!localDir.exists()) { + throw new RuntimeException("Fatal error. LocalDir should be set prior to execution."); + } + if (!target.exists()) { + throw new SubCommandException("PMM was unable to locate the module (" + target.toString() + ")." + + " Are you sure this is the correct customer and module name?"); + } + + return new ModulePointer(localDir, target); + } + + public ModulePointer(File localDir, File targetModule) { + super(); + this.localDir = localDir; + this.targetModule = targetModule; + } + + public File getLocalDir() { + return localDir; + } + + public File getTargetModule() { + return targetModule; + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/ModuleVO.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleVO.java similarity index 83% rename from src/main/java/com/gtnexus/appxpress/platform/module/ModuleVO.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleVO.java index 00e9dd3..68396b3 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/ModuleVO.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/ModuleVO.java @@ -1,14 +1,14 @@ -package com.gtnexus.appxpress.platform.module; +package com.gtnexus.pmm.app.platform.module; import java.util.LinkedList; import java.util.List; -import com.gtnexus.appxpress.platform.module.model.customaction.CustomActionD1; -import com.gtnexus.appxpress.platform.module.model.customlink.CustomLinkD1; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; -import com.gtnexus.appxpress.platform.module.model.template.TemplateMediaV110; -import com.gtnexus.appxpress.platform.module.model.typeextension.TypeExtensionD1; +import com.gtnexus.pmm.app.platform.module.model.customaction.CustomActionD1; +import com.gtnexus.pmm.app.platform.module.model.customlink.CustomLinkD1; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; +import com.gtnexus.pmm.app.platform.module.model.template.TemplateMediaV110; +import com.gtnexus.pmm.app.platform.module.model.typeextension.TypeExtensionD1; public class ModuleVO { diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/CustomObjectDesignV110Comparator.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/CustomObjectDesignV110Comparator.java similarity index 88% rename from src/main/java/com/gtnexus/appxpress/platform/module/interpretation/CustomObjectDesignV110Comparator.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/CustomObjectDesignV110Comparator.java index 6a94c34..e6e3c4b 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/CustomObjectDesignV110Comparator.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/CustomObjectDesignV110Comparator.java @@ -1,9 +1,9 @@ -package com.gtnexus.appxpress.platform.module.interpretation; +package com.gtnexus.pmm.app.platform.module.interpretation; import java.util.Comparator; import com.google.common.collect.Ordering; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; public class CustomObjectDesignV110Comparator implements Comparator { diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/PlatformModuleInterpreter.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/PlatformModuleInterpreter.java similarity index 82% rename from src/main/java/com/gtnexus/appxpress/platform/module/interpretation/PlatformModuleInterpreter.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/PlatformModuleInterpreter.java index cb665c6..17a5895 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/PlatformModuleInterpreter.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/PlatformModuleInterpreter.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.platform.module.interpretation; +package com.gtnexus.pmm.app.platform.module.interpretation; import java.io.File; import java.util.Arrays; @@ -6,12 +6,12 @@ import java.util.List; import java.util.regex.Pattern; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.platform.module.ModuleModelPointer; -import com.gtnexus.appxpress.platform.module.ModulePointer; -import com.gtnexus.appxpress.platform.module.ModuleVO; -import com.gtnexus.appxpress.platform.module.unmarshal.ModuleUnmarshaller; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; +import com.gtnexus.pmm.app.platform.module.ModuleModelPointer; +import com.gtnexus.pmm.app.platform.module.ModulePointer; +import com.gtnexus.pmm.app.platform.module.ModuleVO; +import com.gtnexus.pmm.app.platform.module.unmarshal.ModuleUnmarshaller; public class PlatformModuleInterpreter { @@ -27,11 +27,11 @@ public PlatformModuleInterpreter(ModulePointer root) { this.root = root; } - public ModuleVO interpret() throws AppXpressException { + public ModuleVO interpret() throws SubCommandException { return getVO(); } - protected ModuleVO getVO() throws AppXpressException { + protected ModuleVO getVO() throws SubCommandException { ModuleModelPointer filesForDocumentation = collectFilesForDocumentation(root); ModuleUnmarshaller unmarshaller = new ModuleUnmarshaller(); return unmarshaller.unmarshall(filesForDocumentation); diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/role/security/NormalizedRoleSecurity.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/role/security/NormalizedRoleSecurity.java similarity index 95% rename from src/main/java/com/gtnexus/appxpress/platform/module/interpretation/role/security/NormalizedRoleSecurity.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/role/security/NormalizedRoleSecurity.java index 55e2150..a9dfd63 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/role/security/NormalizedRoleSecurity.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/role/security/NormalizedRoleSecurity.java @@ -1,11 +1,11 @@ -package com.gtnexus.appxpress.platform.module.interpretation.role.security; +package com.gtnexus.pmm.app.platform.module.interpretation.role.security; -import java.util.Map; +import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.TreeMap; -import java.util.LinkedList; -import com.gtnexus.appxpress.platform.module.model.design.RoleSecurity; +import com.gtnexus.pmm.app.platform.module.model.design.RoleSecurity; public class NormalizedRoleSecurity { diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/workflow/WorkflowGraph.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/workflow/WorkflowGraph.java similarity index 88% rename from src/main/java/com/gtnexus/appxpress/platform/module/interpretation/workflow/WorkflowGraph.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/workflow/WorkflowGraph.java index 00024d5..0c0eea2 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/interpretation/workflow/WorkflowGraph.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/interpretation/workflow/WorkflowGraph.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.platform.module.interpretation.workflow; +package com.gtnexus.pmm.app.platform.module.interpretation.workflow; import java.util.Collection; import java.util.LinkedList; @@ -8,9 +8,9 @@ import com.google.common.base.Function; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.gtnexus.appxpress.platform.module.model.design.Step; -import com.gtnexus.appxpress.platform.module.model.design.Transition; -import com.gtnexus.appxpress.platform.module.model.design.Workflow; +import com.gtnexus.pmm.app.platform.module.model.design.Step; +import com.gtnexus.pmm.app.platform.module.model.design.Transition; +import com.gtnexus.pmm.app.platform.module.model.design.Workflow; public class WorkflowGraph { diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/CustomActionD1.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/CustomActionD1.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/CustomActionD1.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/CustomActionD1.java index 3aaa342..b66b3db 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/CustomActionD1.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/CustomActionD1.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.23 at 01:15:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customaction; +package com.gtnexus.pmm.app.platform.module.model.customaction; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/Metadata.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/Metadata.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/Metadata.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/Metadata.java index 4dff042..3d74dec 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/Metadata.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/Metadata.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.23 at 01:15:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customaction; +package com.gtnexus.pmm.app.platform.module.model.customaction; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/ObjectFactory.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/ObjectFactory.java index 1dd8738..e940196 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customaction/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customaction/ObjectFactory.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.23 at 01:15:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customaction; +package com.gtnexus.pmm.app.platform.module.model.customaction; import java.math.BigInteger; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/CustomLinkD1.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/CustomLinkD1.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/CustomLinkD1.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/CustomLinkD1.java index a9cf995..31f8ad5 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/CustomLinkD1.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/CustomLinkD1.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.24 at 05:19:55 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customlink; +package com.gtnexus.pmm.app.platform.module.model.customlink; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/Metadata.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/Metadata.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/Metadata.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/Metadata.java index d482b6e..98b12a4 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/Metadata.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/Metadata.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.24 at 05:19:55 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customlink; +package com.gtnexus.pmm.app.platform.module.model.customlink; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/ObjectFactory.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/ObjectFactory.java index 55083ce..cedd44f 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/customlink/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/customlink/ObjectFactory.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.24 at 05:19:55 PM EDT // -package com.gtnexus.appxpress.platform.module.model.customlink; +package com.gtnexus.pmm.app.platform.module.model.customlink; import java.math.BigInteger; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Anchor.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Anchor.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/Anchor.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Anchor.java index aa3b2f6..e0b7b4a 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Anchor.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Anchor.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/AttachmentFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/AttachmentFeature.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/AttachmentFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/AttachmentFeature.java index c260e03..0b3806c 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/AttachmentFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/AttachmentFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodExtensionPoint.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodExtensionPoint.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodExtensionPoint.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodExtensionPoint.java index c3e4cb9..ffc59de 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodExtensionPoint.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodExtensionPoint.java @@ -5,9 +5,10 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodSection.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodSection.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodSection.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodSection.java index c4e3179..4130de0 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CodSection.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CodSection.java @@ -5,9 +5,10 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CustomObjectDesignV110.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CustomObjectDesignV110.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/CustomObjectDesignV110.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CustomObjectDesignV110.java index 3791371..d59b457 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/CustomObjectDesignV110.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/CustomObjectDesignV110.java @@ -5,11 +5,12 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/EventField.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/EventField.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/EventField.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/EventField.java index cbeabd2..4d7ed41 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/EventField.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/EventField.java @@ -5,9 +5,10 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ExtendedData.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ExtendedData.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/ExtendedData.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ExtendedData.java index f9f5794..cc6b0d9 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ExtendedData.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ExtendedData.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/IntegrationFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/IntegrationFeature.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/IntegrationFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/IntegrationFeature.java index f21b744..d4c8b25 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/IntegrationFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/IntegrationFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/LinkField.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/LinkField.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/LinkField.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/LinkField.java index 982a9ba..f398d87 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/LinkField.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/LinkField.java @@ -5,9 +5,10 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/NavFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/NavFeature.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/NavFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/NavFeature.java index 37b6534..a5bec5b 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/NavFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/NavFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ObjectFactory.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ObjectFactory.java index 932de74..a52b1db 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ObjectFactory.java @@ -5,9 +5,10 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/PdfFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/PdfFeature.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/PdfFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/PdfFeature.java index 0894752..1988648 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/PdfFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/PdfFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ReportingFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ReportingFeature.java similarity index 96% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/ReportingFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ReportingFeature.java index 95f773f..00b9217 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ReportingFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ReportingFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/RoleSecurity.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/RoleSecurity.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/RoleSecurity.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/RoleSecurity.java index b133eb7..275551a 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/RoleSecurity.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/RoleSecurity.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScalarField.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScalarField.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScalarField.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScalarField.java index c36c843..af6a8c3 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScalarField.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScalarField.java @@ -5,11 +5,12 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScriptingFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScriptingFeature.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScriptingFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScriptingFeature.java index 24b49be..74f528b 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/ScriptingFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/ScriptingFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Step.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Step.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/Step.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Step.java index bf204e2..e2006a8 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Step.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Step.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Transition.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Transition.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/Transition.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Transition.java index 0d374df..5f66e03 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Transition.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Transition.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/VersioningFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/VersioningFeature.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/VersioningFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/VersioningFeature.java index 5151c5c..5865da3 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/VersioningFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/VersioningFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Workflow.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Workflow.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/Workflow.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Workflow.java index 86bbecb..b27c687 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/Workflow.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/Workflow.java @@ -5,10 +5,11 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/WorkflowFeature.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/WorkflowFeature.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/design/WorkflowFeature.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/WorkflowFeature.java index cb4bffa..8f5c0bf 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/design/WorkflowFeature.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/design/WorkflowFeature.java @@ -5,7 +5,7 @@ // Generated on: 2016.07.21 at 02:11:26 PM EDT // -package com.gtnexus.appxpress.platform.module.model.design; +package com.gtnexus.pmm.app.platform.module.model.design; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/CustomUiConfiguration.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/CustomUiConfiguration.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/CustomUiConfiguration.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/CustomUiConfiguration.java index bb1a055..ee6eaef 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/CustomUiConfiguration.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/CustomUiConfiguration.java @@ -5,7 +5,7 @@ // Generated on: 2016.06.22 at 04:47:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/Metadata.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/Metadata.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/Metadata.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/Metadata.java index 68e0ca9..c27fb7b 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/Metadata.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/Metadata.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.22 at 04:47:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationConfiguration.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationConfiguration.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationConfiguration.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationConfiguration.java index a325fe9..1bb67de 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationConfiguration.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationConfiguration.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.22 at 04:47:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import java.math.BigInteger; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationTopic.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationTopic.java similarity index 97% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationTopic.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationTopic.java index 709a1f4..8cd207d 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/NotificationTopic.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/NotificationTopic.java @@ -5,7 +5,7 @@ // Generated on: 2016.06.22 at 04:47:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/ObjectFactory.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/ObjectFactory.java index 37caf48..c679394 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/ObjectFactory.java @@ -5,9 +5,10 @@ // Generated on: 2016.06.22 at 04:47:37 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import java.math.BigInteger; + import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleXml.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/PlatformModuleXml.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleXml.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/PlatformModuleXml.java index 8b9a513..26123c9 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleXml.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/platformmodule/PlatformModuleXml.java @@ -5,15 +5,15 @@ // Generated on: 2016.06.24 at 04:32:19 PM EDT // -package com.gtnexus.appxpress.platform.module.model.platformmodule; +package com.gtnexus.pmm.app.platform.module.model.platformmodule; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/template/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/ObjectFactory.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/template/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/ObjectFactory.java index d9cf551..7910107 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/template/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/ObjectFactory.java @@ -5,7 +5,7 @@ // Generated on: 2016.06.27 at 10:43:26 AM EDT // -package com.gtnexus.appxpress.platform.module.model.template; +package com.gtnexus.pmm.app.platform.module.model.template; import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/template/TemplateMediaV110.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/TemplateMediaV110.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/template/TemplateMediaV110.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/TemplateMediaV110.java index cce5121..3638e61 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/template/TemplateMediaV110.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/template/TemplateMediaV110.java @@ -5,7 +5,7 @@ // Generated on: 2016.06.27 at 10:43:26 AM EDT // -package com.gtnexus.appxpress.platform.module.model.template; +package com.gtnexus.pmm.app.platform.module.model.template; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Callbacks.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Callbacks.java similarity index 98% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Callbacks.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Callbacks.java index 830e3c6..8784855 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Callbacks.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Callbacks.java @@ -5,7 +5,7 @@ // Generated on: 2016.04.26 at 06:23:51 PM PDT // -package com.gtnexus.appxpress.platform.module.model.typeextension; +package com.gtnexus.pmm.app.platform.module.model.typeextension; import java.math.BigInteger; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Metadata.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Metadata.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Metadata.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Metadata.java index 31965a1..4c6e31f 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/Metadata.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/Metadata.java @@ -5,7 +5,7 @@ // Generated on: 2016.04.26 at 06:23:51 PM PDT // -package com.gtnexus.appxpress.platform.module.model.typeextension; +package com.gtnexus.pmm.app.platform.module.model.typeextension; import java.math.BigInteger; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/ObjectFactory.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/ObjectFactory.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/ObjectFactory.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/ObjectFactory.java index 66d5f67..a8f54af 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/ObjectFactory.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/ObjectFactory.java @@ -5,7 +5,7 @@ // Generated on: 2016.04.26 at 06:23:51 PM PDT // -package com.gtnexus.appxpress.platform.module.model.typeextension; +package com.gtnexus.pmm.app.platform.module.model.typeextension; import java.math.BigInteger; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/TypeExtensionD1.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/TypeExtensionD1.java similarity index 99% rename from src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/TypeExtensionD1.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/TypeExtensionD1.java index 85c2050..b85a120 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/model/typeextension/TypeExtensionD1.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/model/typeextension/TypeExtensionD1.java @@ -5,7 +5,7 @@ // Generated on: 2016.04.26 at 06:23:51 PM PDT // -package com.gtnexus.appxpress.platform.module.model.typeextension; +package com.gtnexus.pmm.app.platform.module.model.typeextension; import java.math.BigInteger; diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/unmarshal/ModuleUnmarshaller.java b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/unmarshal/ModuleUnmarshaller.java similarity index 75% rename from src/main/java/com/gtnexus/appxpress/platform/module/unmarshal/ModuleUnmarshaller.java rename to mapp/src/main/java/com/gtnexus/pmm/app/platform/module/unmarshal/ModuleUnmarshaller.java index 7847499..020b19c 100644 --- a/src/main/java/com/gtnexus/appxpress/platform/module/unmarshal/ModuleUnmarshaller.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/platform/module/unmarshal/ModuleUnmarshaller.java @@ -1,4 +1,4 @@ -package com.gtnexus.appxpress.platform.module.unmarshal; +package com.gtnexus.pmm.app.platform.module.unmarshal; import java.io.File; import java.io.FileNotFoundException; @@ -10,15 +10,15 @@ import javax.xml.bind.JAXBIntrospector; import javax.xml.bind.Unmarshaller; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.platform.module.ModuleModelPointer; -import com.gtnexus.appxpress.platform.module.ModuleVO; -import com.gtnexus.appxpress.platform.module.model.customaction.CustomActionD1; -import com.gtnexus.appxpress.platform.module.model.customlink.CustomLinkD1; -import com.gtnexus.appxpress.platform.module.model.design.CustomObjectDesignV110; -import com.gtnexus.appxpress.platform.module.model.platformmodule.PlatformModuleXml; -import com.gtnexus.appxpress.platform.module.model.template.TemplateMediaV110; -import com.gtnexus.appxpress.platform.module.model.typeextension.TypeExtensionD1; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.platform.module.ModuleModelPointer; +import com.gtnexus.pmm.app.platform.module.ModuleVO; +import com.gtnexus.pmm.app.platform.module.model.customaction.CustomActionD1; +import com.gtnexus.pmm.app.platform.module.model.customlink.CustomLinkD1; +import com.gtnexus.pmm.app.platform.module.model.design.CustomObjectDesignV110; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; +import com.gtnexus.pmm.app.platform.module.model.template.TemplateMediaV110; +import com.gtnexus.pmm.app.platform.module.model.typeextension.TypeExtensionD1; public class ModuleUnmarshaller { @@ -26,7 +26,7 @@ public ModuleUnmarshaller() { } - public ModuleVO unmarshall(ModuleModelPointer vo) throws AppXpressException { + public ModuleVO unmarshall(ModuleModelPointer vo) throws SubCommandException { ModuleVO.Builder builder = new ModuleVO.Builder(); try { builder.setPlatformModuleXml(unmarshallPlatMod(vo.getPlatformModuleXml())); @@ -46,7 +46,7 @@ public ModuleVO unmarshall(ModuleModelPointer vo) throws AppXpressException { builder.addDesign(unmarshallCustomObjectDesignV110(f)); } } catch (JAXBException | IOException e) { - throw new AppXpressException("Failed to unmarshall the platform module", e); + throw new SubCommandException("Failed to unmarshall the platform module", e); } return builder.build(); } diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/service/EnvironmentServiceImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/service/EnvironmentServiceImpl.java new file mode 100644 index 0000000..2a14e1b --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/service/EnvironmentServiceImpl.java @@ -0,0 +1,56 @@ +package com.gtnexus.pmm.app.service; + +import static com.gtnexus.pmm.app.AppXpressConstants.LIB; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Properties; + +import com.gtnexus.pmm.api.v100.cli.option.options.LocalDirOption; +import com.gtnexus.pmm.api.v100.service.EnvironmentService; +import com.gtnexus.pmm.app.common.PMProperties; + +public class EnvironmentServiceImpl implements EnvironmentService { + + private static final String CWD = "user.dir"; + private final PMProperties properties; + private final String[] rawArgs; + + public EnvironmentServiceImpl(PMProperties properties, String[] rawArgs) { + this.properties = properties; + this.rawArgs = rawArgs; + } + + @Override + public Path getLocalDir() { + String ld = this.properties.getProperty(LocalDirOption.NAME); + return Paths.get(ld); + } + + @Override + public Path getCWD() { + return Paths.get(System.getProperty(CWD)).toAbsolutePath(); + } + + @Override + public Path getAppXDir() { + throw new RuntimeException("Unimplemtned"); + } + + @Override + public Path getLibPath() { + Path ld = this.getLocalDir(); + return ld.getParent().resolve(LIB); + } + + @Override + public Properties getProperties() { + return this.properties.getProperties(); + } + + @Override + public String[] getRawArgs() { + return this.rawArgs; + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/service/FileServiceImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/service/FileServiceImpl.java new file mode 100644 index 0000000..24a7887 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/service/FileServiceImpl.java @@ -0,0 +1,236 @@ +package com.gtnexus.pmm.app.service; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.app.common.file.CopyDirVisitor; +import com.gtnexus.pmm.app.common.file.DeleteDirVisitor; + +/** + * Service class to handle File IO procedures common to app. + * + * @author jdonovan + * + */ +public class FileServiceImpl implements FileService { + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#prependToName(java.io.File, java.lang.String) + */ + @Override + public Path prependToName(File file, String prepend) throws IOException { + return renameFile(file, prepend + file.getName()); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#prependToName(java.io.File, java.lang.String, com.gtnexus.pmm.commons.HasPrerequisite) + */ + @Override + public Path prependToName(File file, String prepend, Predicate precondition) throws IOException { + return renameFile(file, prepend + file.getName(), precondition); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#prependToName(java.util.Collection, java.lang.String) + */ + @Override + public List prependToName(Collection files, String prepend) throws IOException { + return prependToName(files, prepend, Predicates.alwaysTrue()); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#prependToName(java.util.Collection, java.lang.String, com.gtnexus.pmm.commons.HasPrerequisite) + */ + @Override + public List prependToName(Collection files, String prepend, Predicate precondition) + throws IOException { + List paths = new LinkedList<>(); + for (File file : files) { + paths.add(prependToName(file, prepend, precondition)); + } + return paths; + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#renameFile(java.io.File, java.lang.String) + */ + @Override + public Path renameFile(File file, String newName) throws IOException { + return renameFile(file, newName, Predicates.alwaysTrue()); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#renameFile(java.io.File, java.lang.String, com.gtnexus.pmm.commons.HasPrerequisite) + */ + @Override + public Path renameFile(File file, String newName, Predicate precondition) throws IOException { + Path path = file.toPath(); + if (!precondition.apply(file)) + return path; + try { + path = Files.move(file.toPath(), file.toPath().resolveSibling(newName)); + } catch (IOException e) { + throw new IOException("Exception when trying to rename " + file.getAbsolutePath(), e); + } + return path; + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#renameFile(java.util.Collection, java.lang.String, java.lang.String) + */ + @Override + public List renameFile(Collection files, String toReplace, String replacement) throws IOException { + return renameFile(files, toReplace, replacement, Predicates.alwaysTrue()); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#renameFile(java.util.Collection, java.lang.String, java.lang.String, com.gtnexus.pmm.commons.HasPrerequisite) + */ + @Override + public List renameFile(Collection files, String toReplace, String replacement, + Predicate precondition) throws IOException { + Preconditions.checkNotNull(files, "Files to rename cannot be null."); + Preconditions.checkNotNull(toReplace, "String to be replaced cannot be null"); + Preconditions.checkNotNull(replacement, "Replacement string cannot be null"); + List paths = new LinkedList<>(); + for (File file : files) { + String fileName = file.getName(); + Path result = renameFile(file, fileName.replace(toReplace, replacement), precondition); + paths.add(result); + } + return paths; + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#moveFiles(java.util.Collection, java.io.File) + */ + @Override + public List moveFiles(final Collection files, final File destination) throws IOException { + if (files == null || destination == null) { + throw new NullPointerException("files and destination cannot be null."); + } + if (!destination.isDirectory()) { + throw new IllegalArgumentException("Destination must be a directory."); + } + List paths = new LinkedList<>(); + for (File file : files) { + Path p = destination.toPath().resolve(file.getName()); + Path result = Files.move(file.toPath(), p, StandardCopyOption.REPLACE_EXISTING); + paths.add(result); + } + return paths; + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#copyFiles(java.util.Collection, java.io.File, com.gtnexus.pmm.commons.HasPrerequisite) + */ + @Override + public List copyFiles(final Collection files, final File destination, + Predicate precondition) throws IOException { + Preconditions.checkArgument(files != null && destination != null, "files and destination cannot be null."); + Preconditions.checkArgument(destination.isDirectory(), + "Destination " + destination.getName() + " is not a directory."); + if (precondition == null) { + precondition = Predicates.alwaysTrue(); + } + return _copyFiles(files, destination, precondition); + } + + private List _copyFiles(final Collection files, final File destination, + Predicate precondition) throws IOException { + List paths = new LinkedList<>(); + for (File file : files) { + Path result = _copyFile(destination, precondition, file); + if (result != null) + paths.add(result); + } + return paths; + } + + private Path _copyFile(final File destination, Predicate precondition, File file) throws IOException { + if (precondition.apply(file)) { + Path p = destination.toPath().resolve(file.getName()); + return Files.copy(file.toPath(), p, StandardCopyOption.REPLACE_EXISTING); + } + return null; + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#copyDirectory(java.io.File, java.io.File) + */ + @Override + public Path copyDirectory(File sourceDir, File destination) throws IOException { + return copyDirectory(sourceDir.toPath(), destination.toPath()); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#copyDirectory(java.nio.file.Path, java.nio.file.Path) + */ + @Override + public Path copyDirectory(Path source, Path destination) throws IOException { + if (!Files.exists(source)) { + throw new IOException("Cannot copy directory tree from source: " + source.toString() + + ". Source directory does not exist."); + } + if (destination.startsWith(source)) { + throw new IllegalArgumentException("Cannot copy directory structure into subdirectory of itself."); + } + if (!Files.exists(destination)) { + Files.createDirectories(destination); + } + CopyDirVisitor visitor = new CopyDirVisitor(source, destination); + return Files.walkFileTree(source, visitor); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#isFileType(java.io.File, java.lang.String) + */ + @Override + public boolean isFileType(final File file, final String extension) { + return file.getName().endsWith(extension); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#emptyDir(java.io.File) + */ + @Override + public void emptyDir(final File root) throws IOException { + emptyDir(root, false); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#emptyDir(java.nio.file.Path) + */ + @Override + public void emptyDir(final Path root) throws IOException { + emptyDir(root, false); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#emptyDir(java.io.File, boolean) + */ + @Override + public void emptyDir(final File root, boolean deleteRoot) throws IOException { + emptyDir(root.toPath(), deleteRoot); + } + + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.file.FileService#emptyDir(java.nio.file.Path, boolean) + */ + @Override + public void emptyDir(final Path root, boolean deleteRoot) throws IOException { + DeleteDirVisitor visitor = new DeleteDirVisitor(root, deleteRoot); + Files.walkFileTree(root, visitor); + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/service/PlatformModuleManagerServicesImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/service/PlatformModuleManagerServicesImpl.java new file mode 100644 index 0000000..52731c1 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/service/PlatformModuleManagerServicesImpl.java @@ -0,0 +1,44 @@ +package com.gtnexus.pmm.app.service; + +import com.gtnexus.pmm.api.v100.service.EnvironmentService; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.api.v100.service.PlatformModuleManagerServices; +import com.gtnexus.pmm.api.v100.service.TemporaryResourceService; +import com.gtnexus.pmm.api.v100.service.ZipService; +import com.gtnexus.pmm.app.common.PMProperties; + +public class PlatformModuleManagerServicesImpl implements PlatformModuleManagerServices { + + private final EnvironmentService es; + private final FileService fs; + private final TemporaryResourceService ts; + private final ZipService zs; + + public PlatformModuleManagerServicesImpl(PMProperties properties, String[] args) { + this.fs = new FileServiceImpl(); + this.zs = new ZipServiceImpl(); + this.es = new EnvironmentServiceImpl(properties, args); + this.ts = new TemporaryResourceServiceImpl(); + } + + @Override + public ZipService getZipService() { + return this.zs; + } + + @Override + public FileService getFileService() { + return this.fs; + } + + @Override + public TemporaryResourceService getTemporaryResourceService() { + return ts; + } + + @Override + public EnvironmentService getEnvironmentService() { + return this.es; + } + +} diff --git a/mapp/src/main/java/com/gtnexus/pmm/app/service/TemporaryResourceServiceImpl.java b/mapp/src/main/java/com/gtnexus/pmm/app/service/TemporaryResourceServiceImpl.java new file mode 100644 index 0000000..105f607 --- /dev/null +++ b/mapp/src/main/java/com/gtnexus/pmm/app/service/TemporaryResourceServiceImpl.java @@ -0,0 +1,15 @@ +package com.gtnexus.pmm.app.service; + +import java.io.File; + +import com.gtnexus.pmm.api.v100.service.TemporaryResourceService; + +public class TemporaryResourceServiceImpl implements TemporaryResourceService { + + @Override + public void markForDeletion(File f) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/main/java/com/gtnexus/appxpress/commons/ZipService.java b/mapp/src/main/java/com/gtnexus/pmm/app/service/ZipServiceImpl.java similarity index 66% rename from src/main/java/com/gtnexus/appxpress/commons/ZipService.java rename to mapp/src/main/java/com/gtnexus/pmm/app/service/ZipServiceImpl.java index 7279c91..97d3789 100644 --- a/src/main/java/com/gtnexus/appxpress/commons/ZipService.java +++ b/mapp/src/main/java/com/gtnexus/pmm/app/service/ZipServiceImpl.java @@ -1,6 +1,6 @@ -package com.gtnexus.appxpress.commons; +package com.gtnexus.pmm.app.service; -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; +import static com.gtnexus.pmm.app.AppXpressConstants.ZIP_EXTENSION; import java.io.File; import java.io.FileInputStream; @@ -14,8 +14,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.api.v100.service.ZipService; import net.lingala.zip4j.core.ZipFile; import net.lingala.zip4j.exception.ZipException; @@ -28,28 +29,32 @@ * @version 1.0 * @date 8-27-2014 GT Nexus */ -public class ZipService { +public class ZipServiceImpl implements ZipService { private final FileService fs; private final Set ignoreSet; - public ZipService() { - this(Collections. emptySet()); + public ZipServiceImpl() { + this(Collections.emptySet()); } - public ZipService(Set ignoreDirNames) { - this.fs = new FileService(); + public ZipServiceImpl(Set ignoreDirNames) { + this.fs = new FileServiceImpl(); this.ignoreSet = ignoreDirNames; } - public void zipFiles(Collection files, String absPathToDestinationZip) throws AppXpressException { + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#zipFiles(java.util.Collection, java.lang.String) + */ + @Override + public void zipFiles(Collection files, String absPathToDestinationZip) throws SubCommandException { try (FileOutputStream fos = new FileOutputStream(absPathToDestinationZip); ZipOutputStream zos = new ZipOutputStream(fos)) { for (File f : files) { zipSingle(zos, f); } } catch (IOException e) { - throw new AppXpressException("Error when zipping collection of files", e); + throw new SubCommandException("Error when zipping collection of files", e); } } @@ -65,47 +70,41 @@ private void zipSingle(ZipOutputStream zos, File f) throws IOException { } } - public void zipDirectory(Path directory) throws AppXpressException { + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#zipDirectory(java.nio.file.Path) + */ + @Override + public void zipDirectory(Path directory) throws SubCommandException { zipDirectory(directory.toFile()); } - /** - * Packs the given directory into a a zip file named after the directory. - * - * @param directoryPath - * - the directory that is going to be packed - * @throws IOException + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#zipDirectory(java.io.File) */ - public void zipDirectory(File directory) throws AppXpressException { + @Override + public void zipDirectory(File directory) throws SubCommandException { if (!directory.exists() || !directory.isDirectory()) { - throw new AppXpressException("No such directory" + directory.getAbsolutePath()); + throw new SubCommandException("No such directory" + directory.getAbsolutePath()); } String outputZip = directory.getAbsolutePath() + ZIP_EXTENSION; zipDirectory(directory, outputZip); } - /** - * Packs the given directory into a a zip file named after the directory. - * - * @param directoryPath - * - the directory that is going to be packed - * @throws IOException + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#zipDirectory(java.io.File, java.lang.String) */ - public void zipDirectory(File directory, String outputZip) throws AppXpressException { + @Override + public void zipDirectory(File directory, String outputZip) throws SubCommandException { zipDirectory(directory, new File(outputZip)); } - /** - * Packs the given directory into the zip file pointer. If the outputZip does - * not end with .zip it is appended. - * - * @param directory - * @param outputZip - * @throws AppXpressException + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#zipDirectory(java.io.File, java.io.File) */ - public void zipDirectory(File directory, File outputZip) throws AppXpressException { + @Override + public void zipDirectory(File directory, File outputZip) throws SubCommandException { if (!directory.exists() || !directory.isDirectory()) { - throw new AppXpressException("No such directory " + directory.getAbsolutePath()); + throw new SubCommandException("No such directory " + directory.getAbsolutePath()); } if (!outputZip.getName().endsWith(ZIP_EXTENSION)) { outputZip = new File(outputZip.toString() + ZIP_EXTENSION); @@ -115,7 +114,7 @@ public void zipDirectory(File directory, File outputZip) throws AppXpressExcepti zipDirFiles(directory, directory, zos); zos.closeEntry(); } catch (IOException e) { - throw new AppXpressException("Exception when recursively zipping " + directory.getAbsolutePath(), e); + throw new SubCommandException("Exception when recursively zipping " + directory.getAbsolutePath(), e); } } @@ -153,19 +152,27 @@ private String zipName(File root, File file) throws IOException { file.getCanonicalPath().length()); } - public void unzip(File source, File destination, boolean recurse) throws AppXpressException { + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#unzip(java.io.File, java.io.File, boolean) + */ + @Override + public void unzip(File source, File destination, boolean recurse) throws SubCommandException { unzip(source, destination); if (recurse) { recurseUnzip(destination); } } - public void unzip(File source, File destination) throws AppXpressException { + /* (non-Javadoc) + * @see com.gtnexus.pmm.commons.ZipService#unzip(java.io.File, java.io.File) + */ + @Override + public void unzip(File source, File destination) throws SubCommandException { try { ZipFile zip = new ZipFile(source); zip.extractAll(destination.getAbsolutePath()); } catch (ZipException e) { - throw new AppXpressException("Exception when unzipping", e); + throw new SubCommandException("Exception when unzipping", e); } } @@ -179,7 +186,7 @@ public void unzip(File source, File destination) throws AppXpressException { * @param path * Destination of file structure to iterate over */ - private void recurseUnzip(File f) throws AppXpressException { + private void recurseUnzip(File f) throws SubCommandException { if (f.isDirectory() && !ignoreSet.contains(f.getName())) { for (File item : f.listFiles()) { recurseUnzip(item); diff --git a/mapp/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java b/mapp/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java new file mode 100644 index 0000000..f363f4a --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java @@ -0,0 +1,28 @@ +package com.gtnexus.appxpress; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +public class AppXpressExceptionTest { + + @Test + public void testGetMessage() { + StringBuilder sb = new StringBuilder(); + String[] ss = {"1", "2", "3", "4" }; + for (String s : ss) { + sb.append(s); + sb.append("\n"); + } + String expected = sb.toString().trim(); + SubCommandException root = new SubCommandException(ss[ss.length - 1]); + for (int i = ss.length - 2; i >= 0; i--) { + root = new SubCommandException(ss[i], root); + } + String actual = root.getAppXpressMessage(); + assertEquals(expected, actual); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/NullOutputStream.java b/mapp/src/test/java/com/gtnexus/appxpress/NullOutputStream.java new file mode 100644 index 0000000..8d9fbde --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/NullOutputStream.java @@ -0,0 +1,27 @@ +package com.gtnexus.appxpress; + +import java.io.IOException; +import java.io.OutputStream; + +/** + * You can think of me as writing to /dev/null. + * + * Created by jjdonov on 10/15/14. + */ +public class NullOutputStream extends OutputStream { + + @Override + public void write(int b) throws IOException { + + } + + @Override + public void write(byte[] b) throws IOException { + super.write(b); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + super.write(b, off, len); + } +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java b/mapp/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java new file mode 100644 index 0000000..fb65a29 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java @@ -0,0 +1,39 @@ +package com.gtnexus.appxpress.cli.option; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.EnumSet; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.collect.ImmutableSet; +import com.gtnexus.appxpress.pmextractor.cli.DummyOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOptionParser; +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +public class CLICommandOptionParserTest { + + private final Set optSet = new ImmutableSet.Builder().add(DummyOption.DUMMY).build(); + private final CommandOptionParser parser = CommandOptionParser.createParser(optSet); + + @Test + public void testParse() throws Exception { + Map parsedOpts = parser.parse(new String[] {"-Dummy"}); + assertTrue(parsedOpts.containsKey(DummyOption.DUMMY)); + } + + @Test(expected = SubCommandException.class) + public void testParseWithInvalidOpt() throws Exception { + parser.parse(new String[] {"-invalidOpt"}); + } + + @Test + public void testGetCliOptionSet() throws Exception { + assertEquals(EnumSet.allOf(DummyOption.class), parser.getCliOptionSet()); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java b/mapp/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java new file mode 100644 index 0000000..c5487f9 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java @@ -0,0 +1,28 @@ +package com.gtnexus.appxpress.commons; + +import static org.junit.Assert.assertFalse; + +import java.io.IOException; +import java.util.Properties; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.PMProperties; + +public class PMPropertiesTest { + + @Rule + public TemporaryFolder sourceDir = new TemporaryFolder(); + + @Test + public void testPropertiesChange() throws IOException { + Properties raw = new Properties(); + raw.put("foo", "bar"); + PMProperties pmProperties = new PMProperties(raw, sourceDir.newFile()); + pmProperties.put("foo", "bar"); + assertFalse("Expected no change to properties file", pmProperties.haveChanged()); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java new file mode 100644 index 0000000..66c7df3 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java @@ -0,0 +1,52 @@ +package com.gtnexus.appxpress.file; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.file.CopyDirVisitor; + +public class CopyDirVisitorTest { + + @Rule + public TemporaryFolder sourceDir = new TemporaryFolder(); + @Rule + public TemporaryFolder destinationDir = new TemporaryFolder(); + + @Test + public void testPreVisitDirectory() throws IOException { + File subDir = sourceDir.newFolder("subDir"); + SimpleFileVisitor visitor = new CopyDirVisitor(sourceDir.getRoot().toPath(), + destinationDir.getRoot().toPath()); + Path path = subDir.toPath(); + BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class); + visitor.preVisitDirectory(path, attributes); + Path p = destinationDir.getRoot().toPath().resolve(subDir.getName()); + File f = p.toFile(); + assertEquals(true, f.exists()); + assertEquals(true, f.isDirectory()); + } + + @Test + public void testVisitFile() throws IOException { + File file = sourceDir.newFile("file1"); + File sourceRoot = sourceDir.getRoot(); + File destinationRoot = destinationDir.getRoot(); + SimpleFileVisitor visitor = new CopyDirVisitor(sourceRoot.toPath(), destinationRoot.toPath()); + Path path = file.toPath(); + BasicFileAttributes attributes = Files.readAttributes(path, BasicFileAttributes.class); + visitor.visitFile(path, attributes); + Path destinationFilePath = destinationRoot.toPath().resolve(path); + assertEquals(true, Files.exists(destinationFilePath)); + } + +} \ No newline at end of file diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java new file mode 100644 index 0000000..bac3bbb --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java @@ -0,0 +1,58 @@ +package com.gtnexus.appxpress.file; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.file.DeleteDirVisitor; + +public class DeleteDirVisitorTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Test + public void testVisitFile() throws IOException { + File f = tmp.newFile(); + Path p = f.toPath(); + DeleteDirVisitor vis = new DeleteDirVisitor(tmp.getRoot().toPath(), false); + BasicFileAttributes attributes = Files.readAttributes(p, BasicFileAttributes.class); + assertEquals(true, Files.exists(p)); + vis.visitFile(p, attributes); + assertEquals(false, Files.exists(p)); + } + + @Test + public void testPostVisitDirectory() throws IOException { + File f = tmp.newFolder(); + Path p = f.toPath(); + DeleteDirVisitor vis = new DeleteDirVisitor(tmp.getRoot().toPath(), false); + vis.postVisitDirectory(p, null); + assertEquals(false, Files.exists(p)); + } + + @Test + public void testPostVisitRoot() throws IOException { + Path path = tmp.getRoot().toPath(); + DeleteDirVisitor vis = new DeleteDirVisitor(path, false); + vis.postVisitDirectory(path, null); + assertEquals(true, Files.exists(path)); + } + + @Test + public void testPostVisitAndDeleteRoot() throws IOException { + Path path = tmp.getRoot().toPath(); + DeleteDirVisitor vis = new DeleteDirVisitor(path, true); + vis.postVisitDirectory(path, null); + assertEquals(false, Files.exists(path)); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java new file mode 100644 index 0000000..c5c6b78 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java @@ -0,0 +1,169 @@ +package com.gtnexus.appxpress.file; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.google.common.base.Predicate; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.app.service.FileServiceImpl; + +public class FileServiceTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + private FileService fs = new FileServiceImpl(); + + @Test + public void testPrependToName() throws IOException { + File f = tmp.newFile("burger"); + Path result = fs.prependToName(f, "cheese"); + assertEquals("cheeseburger", result.toFile().getName()); + } + + @Test(expected = IOException.class) + public void testPrependToNonExistingFile() throws IOException { + File f = new File("burger"); + Path result = fs.prependToName(f, "cheese"); + assertEquals("cheeseburger", result.toFile().getName()); + } + + @Test + public void testPrependToCollection() throws IOException { + for (int i = 0; i < 10; i++) { + tmp.newFile(); + } + File f = tmp.getRoot(); + String prependString = "octo"; + fs.prependToName(Arrays.asList(f.listFiles()), prependString); + for (File file : f.listFiles()) { + assertEquals(true, file.getName().startsWith(prependString)); + } + } + + @Test + public void testRenameFile() throws IOException { + File f = tmp.newFile("prince"); + fs.renameFile(f, "king"); + assertEquals(false, f.exists()); + f = tmp.getRoot().listFiles()[0]; + assertEquals("king", f.getName()); + } + + @Test + public void testRenameCollection() throws IOException { + String toReplace = "gucci"; + for (int i = 0; i < 10; i++) { + tmp.newFile(toReplace + "_" + i); + } + File f = tmp.getRoot(); + + fs.renameFile(Arrays.asList(f.listFiles()), toReplace, "coffee"); + for (File file : f.listFiles()) { + assertEquals(true, file.getName().startsWith("coffee_")); + } + } + + @Test + public void testRenameEmptyCollection() throws IOException { + List p = fs.renameFile(new ArrayList(), "whatever", "kitty"); + assertEquals(0, p.size()); + } + + @Test + public void testMoveFiles() throws IOException { + TemporaryFolder source = new TemporaryFolder(tmp.getRoot()); + source.create(); + for (int i = 0; i < 10; i++) { + source.newFile(); + } + File destination = tmp.newFolder("dest"); + fs.moveFiles(Arrays.asList(source.getRoot().listFiles()), destination); + assertEquals(0, source.getRoot().list().length); + assertEquals(10, destination.list().length); + } + + @Test + public void testMoveEmptyCollection() throws IOException { + File destination = tmp.newFolder("dest"); + fs.moveFiles(new ArrayList(), destination); + assertEquals(0, destination.list().length); + } + + @Test + public void testCopyFiles() throws IOException { + final String[] extension = { ".js", ".zip" }; + Predicate pre = new Predicate() { + + @Override + public boolean apply(File f) { + return f.getName().endsWith(extension[0]); + } + + }; + TemporaryFolder source = new TemporaryFolder(tmp.getRoot()); + source.create(); + for (int i = 0; i < 10; i++) { + source.newFile(i + extension[i % 2]); + } + File destination = tmp.newFolder("destination"); + fs.copyFiles(Arrays.asList(source.getRoot().listFiles()), destination, pre); + assertTrue(destination.list().length > 0); + for (File f : destination.listFiles()) { + assertEquals(true, f.getName().endsWith(extension[0])); + } + } + + @Test + public void testCopyFilesWithNullPrecondition() throws IOException { + final String[] extension = { ".js", ".zip" }; + TemporaryFolder source = new TemporaryFolder(tmp.getRoot()); + source.create(); + for (int i = 0; i < 10; i++) { + source.newFile(i + extension[i % 2]); + } + File destination = tmp.newFolder("destination"); + fs.copyFiles(Arrays.asList(source.getRoot().listFiles()), destination, null); + assertTrue(destination.list().length > 0); + assertEquals(source.getRoot().list().length, destination.list().length); + String[] destFiles = destination.list(); + String[] sourceFiles = source.getRoot().list(); + Arrays.sort(destFiles); + Arrays.sort(sourceFiles); + for (int i = 0; i < destFiles.length; i++) { + assertEquals(sourceFiles[i], destFiles[i]); + } + } + + @Ignore("Not yet implemented.") + @Test + public void testIsFileType() { + + } + + @Ignore("Not yet implemented.") + @Test + public void testCopyDirectory() { + fail("Not yet implemented."); + } + + @Ignore("Not yet implemented.") + @Test + public void testEmptyDir() { + fail("Not yet implemented."); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java new file mode 100644 index 0000000..a28e9bb --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java @@ -0,0 +1,42 @@ +package com.gtnexus.appxpress.file.filter; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.file.filter.ChainedAnd; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; + +public class ChainedAndTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Test + public void testAccept() throws IOException { + tmp.newFile("File"); + tmp.newFile("File2"); + tmp.newFile("file3"); + File root = tmp.getRoot(); + File[] result = root.listFiles( + new ChainedAnd(FileFilterFactory.fileNameContains("File"), FileFilterFactory.fileNameContains("2"))); + assertEquals(1, result.length); + assertEquals("File2", result[0].getName()); + } + + @Test + public void testEmptyChain() throws IOException { + tmp.newFile("File"); + tmp.newFile("File2"); + tmp.newFile("file3"); + File root = tmp.getRoot(); + File[] result = root.listFiles(new ChainedAnd()); + assertEquals(3, result.length); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java new file mode 100644 index 0000000..6b58110 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java @@ -0,0 +1,48 @@ +package com.gtnexus.appxpress.file.filter; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.file.filter.ChainedOr; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; + +public class ChainedOrTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Test + public void testBasicAccept() throws IOException { + tmp.newFile("booger.json"); + tmp.newFile("snot.xml"); + File root = tmp.getRoot(); + File[] result = root.listFiles( + new ChainedOr(FileFilterFactory.endsWith(".json"), FileFilterFactory.fileNameContains("snot"))); + assertEquals(2, result.length); + } + + @Test + public void testEmptyChain() throws IOException { + tmp.newFile("booger.json"); + tmp.newFile("snot.xml"); + File root = tmp.getRoot(); + File[] result = root.listFiles(new ChainedOr()); + assertEquals(2, result.length); + } + + @Test + public void testSingleFilter() throws IOException { + tmp.newFile("booger.json"); + tmp.newFile("snot.xml"); + File root = tmp.getRoot(); + File[] result = root.listFiles(new ChainedOr(FileFilterFactory.endsWith(".json"))); + assertEquals(1, result.length); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java new file mode 100644 index 0000000..3b6bfce --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java @@ -0,0 +1,64 @@ +package com.gtnexus.appxpress.file.filter; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileFilter; +import java.io.IOException; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; + +public class FileFilterFactoryTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Test + public void testFileNameContains() { + FileFilter filter = FileFilterFactory.fileNameContains("coke"); + assertFalse(filter.accept(new File("pepsi"))); + assertTrue(filter.accept(new File("coke"))); + assertTrue(filter.accept(new File("coke-a-doo-doo"))); + } + + @Test + public void testFileNameDoesNotContain() { + FileFilter filter = FileFilterFactory.fileNameDoesNotContain("sausage"); + assertFalse(filter.accept(new File("chicken sausage"))); + assertTrue(filter.accept(new File("cheeseburger"))); + } + + @Test + public void testDirectoriesOnly() throws IOException { + tmp.newFolder(); + tmp.newFolder(); + tmp.newFolder(); + tmp.newFile(); + File[] results = tmp.getRoot().listFiles(FileFilterFactory.directoriesOnly()); + assertEquals(3, results.length); + } + + @Test + public void testEndsWith() { + FileFilter filter = FileFilterFactory.endsWith("tie"); + assertTrue(filter.accept(new File("bowtie"))); + assertTrue(filter.accept(new File("bow.tie"))); + assertFalse(filter.accept(new File("scarf"))); + } + + @Test + public void testDoesNotEndWith() { + FileFilter filter = FileFilterFactory.doesNotEndWith("tie"); + assertFalse(filter.accept(new File("bowtie"))); + assertFalse(filter.accept(new File("bow.tie"))); + assertTrue(filter.accept(new File("scarf"))); + + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java b/mapp/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java new file mode 100644 index 0000000..7ad520f --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java @@ -0,0 +1,30 @@ +package com.gtnexus.appxpress.platform.module.model.platformmodule; + +import static org.junit.Assert.assertNotNull; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.JAXBIntrospector; +import javax.xml.bind.Unmarshaller; + +import org.junit.Test; + +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; + +public class PlatformModuleTest { + + @Test + public void testUnmarshall() throws FileNotFoundException, JAXBException { + File file = new File("src/test/resources/PlatformModule.xml"); + FileReader reader = new FileReader(file); + JAXBContext context = JAXBContext.newInstance("com.gtnexus.pmm.app.platform.module.model.platformmodule"); + Unmarshaller unmarshaller = context.createUnmarshaller(); + PlatformModuleXml platformMod = (PlatformModuleXml) JAXBIntrospector.getValue(unmarshaller.unmarshal(reader)); + assertNotNull(platformMod); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java new file mode 100644 index 0000000..c8a1c0d --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java @@ -0,0 +1,37 @@ +package com.gtnexus.appxpress.pmbuilder; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.PrintStream; +import java.util.Arrays; + +import org.junit.Test; +import org.mockito.Matchers; +import org.mockito.Mockito; + +import com.gtnexus.appxpress.NullOutputStream; +import com.gtnexus.pmm.api.v100.cli.FileSelector; +import com.gtnexus.pmm.api.v100.cli.prompt.BoundIntegerAsker; + +public class PlatformSelectorTest { + + @Test + public void testSelect() { + PrintStream out = null; + try { + File[] files = new File[10]; + for (int i = 0; i < 10; i++) { + files[i] = new File("File" + i); + } + BoundIntegerAsker asker = Mockito.mock(BoundIntegerAsker.class); + Mockito.when(asker.prompt(Matchers.anyString())).thenReturn(1); + out = new PrintStream(new NullOutputStream()); + FileSelector selector = new FileSelector(asker); + File f = selector.select(Arrays.asList(files)); + assertEquals(files[0], f); + } finally { + out.close(); + } + } +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java new file mode 100644 index 0000000..53d3667 --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java @@ -0,0 +1,59 @@ +package com.gtnexus.appxpress.pmbuilder.scriptimport; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.io.File; +import java.io.IOException; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.gtnexus.pmm.app.build.scriptimport.ImportFile; + +public class ImportFileTest { + + @Rule + public TemporaryFolder tmp = new TemporaryFolder(); + + @Test + public void testListFilesWithoutValidFile() { + ImportFile f = new ImportFile(""); + ImportFile[] fs = f.listFiles(); + assertNull(fs); + } + + @Test + public void testListFiles() throws IOException { + int max = 10; + for (int i = 0; i < max; i++) { + tmp.newFile(); + } + ImportFile f = new ImportFile(tmp.getRoot()); + ImportFile[] files = f.listFiles(); + assertEquals(max, files.length); + } + + @Test + public void testCouldHaveImportsWithDir() throws IOException { + File d = tmp.newFolder(); + ImportFile f = new ImportFile(d); + assertEquals(false, f.couldHaveImports()); + } + + @Test + public void testCouldHaveImportsWithFile() throws IOException { + File f = tmp.newFile("test.js"); + ImportFile ff = new ImportFile(f); + assertEquals(true, ff.couldHaveImports()); + } + + @Test + public void testCouldHaveImportsWithBlacklistedExtensions() throws IOException { + File f = tmp.newFile("invalid.zip"); + ImportFile ff = new ImportFile(f); + assertEquals(false, ff.couldHaveImports()); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java new file mode 100644 index 0000000..410d96d --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java @@ -0,0 +1,44 @@ +package com.gtnexus.appxpress.pmbuilder.scriptimport; + +import static org.junit.Assert.assertTrue; + +import java.io.StringReader; +import java.util.Set; + +import org.junit.Test; + +import com.gtnexus.pmm.app.build.scriptimport.ImportScanner; + +public class ImportScannerTest { + + @Test + public void testSingleLineSingleImport() { + ImportScanner scanner = new ImportScanner(); + String testString = "//!import someTestFile"; + StringReader testReader = new StringReader(testString); + Set fileNames = scanner.parseDoc(testReader); + assertTrue(fileNames != null); + assertTrue(!fileNames.isEmpty()); + } + + @Test + public void testSingleLineMultiImport() { + ImportScanner scanner = new ImportScanner(); + String testString = "//!import someTestFile, anotherTestFile"; + StringReader testReader = new StringReader(testString); + Set fileNames = scanner.parseDoc(testReader); + assertTrue(fileNames != null && !fileNames.isEmpty()); + assertTrue(fileNames.size() == 2); + } + + @Test + public void testBlockCommentSingleImport() { + ImportScanner scanner = new ImportScanner(); + String testString = "/*\n* !import someTestFile\n*/"; + StringReader testReader = new StringReader(testString); + Set fileNames = scanner.parseDoc(testReader); + assertTrue(fileNames != null); + assertTrue(!fileNames.isEmpty()); + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java b/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java new file mode 100644 index 0000000..abf44cb --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java @@ -0,0 +1,38 @@ +package com.gtnexus.appxpress.pmextractor; + +import static junit.framework.TestCase.fail; + +import java.io.File; + +import org.junit.Test; + +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.manager.DirectoryHelper; + +/** + * Created by jjdonov on 9/29/14. + */ +@Deprecated +public class DirectoryHelperTest { + + @Test(expected = SubCommandException.class) + public void testWithoutEnsuring() throws SubCommandException { + DirectoryHelper directoryHelper = new DirectoryHelper("test"); + directoryHelper.getPmProperties(); + } + + @Test + public void testWithHomeDirectory() { + DirectoryHelper directoryHelper = new DirectoryHelper("test"); + try { + directoryHelper.ensureAppXpress(); + File propFile = directoryHelper.getPmProperties().getPropertiesFile(); + if (propFile == null || !propFile.exists()) { + fail("Property file does not exist"); + } + } catch (SubCommandException e) { + fail("Exception when ensuring\n" + e.getMessage()); + } + } + +} diff --git a/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java b/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java new file mode 100644 index 0000000..53647ee --- /dev/null +++ b/mapp/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java @@ -0,0 +1,34 @@ +package com.gtnexus.appxpress.pmextractor.cli; + +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; + +public enum DummyOption implements CommandOption { + + DUMMY; + + @Override + public String getLongName() { + return "Dummy"; + } + + @Override + public Class getType() { + return String.class; + } + + @Override + public String getDescription() { + return "Dummy description"; + } + + @Override + public boolean hasArg() { + return false; + } + + @Override + public String getFlag() { + return "d"; + } + +} diff --git a/mapp/src/test/resources/Design_ParcelTrackerS1.xml b/mapp/src/test/resources/Design_ParcelTrackerS1.xml new file mode 100644 index 0000000..e4375d1 --- /dev/null +++ b/mapp/src/test/resources/Design_ParcelTrackerS1.xml @@ -0,0 +1 @@ +0$ParcelTrackerS1ParcelTrackerObject modeling the status of a single parcel package.naturalIdentifierPRIMARYparcelTrackingId1The tracking Id designated by the carrier.10TEXTTEXTtruetrue200READONLYTABINDEXTEXTAREAROWSgtnxCarrierCode2The carrier code identifying the carrier of the parcel.20TEXTTEXTtruetrue200READONLYTABINDEXTEXTAREAROWSlicensePlateNumber3The LPN of the package.30TEXTTEXTtruefalse200READONLYTABINDEXTEXTAREAROWSmanifestReferenceNumber5Id for the manifest this parcel is linked to.40TEXTTEXTtruefalse200READONLYTABINDEXTEXTAREAROWSworkflowState450TEXTTEXTtruetrue200READONLYTABINDEXTEXTAREAROWSdateCreated660DATEDATEtruefalse200READONLYTABINDEXTEXTAREAROWSdateLastModified770DATEDATEfalsefalse200READONLYTABINDEXTEXTAREAROWSbuyer880COMPLEXPARTYfalsefalse200READONLYROLEBuyerTABINDEXTEXTAREAROWSseller990COMPLEXPARTYfalsefalse200READONLYROLESellerTABINDEXTEXTAREAROWSnaturalIdentifier10The natural identifier of this type.5TEXTTEXTtruetrue200READONLYTABINDEXTEXTAREAROWSpackingListUid11The parent packingLists's UID.35TEXTTEXTtruefalse200READONLYTABINDEXTEXTAREAROWSitems1100itemInformationNORMALtruereferences2110referenceREADONLYtruetrueworkflowState$$ParcelTrackerS1CodWorkflowDesignNewObjectCreator,Licensee,BuyerNewfalseObjectCreator,LicenseeonDeliveryDeliveredfalseObjectCreator,Licensee,BuyerDeletedtrueNewDeliveredDeliverObjectCreator,Licensee,BuyerNewDeletedPermanentlyDeleteObjectCreator,Licensee,BuyerDeliveredNewUndeliverObjectCreator,Licensee,BuyerparcelTrackerResetPreConditionhardResettruetext/javascriptScriptDesign_ParcelTrackerS1.jsScriptDesign_$ParcelTrackerS1.jstruetruetrueprocessINSTANCEBuyercreateLicenseecreateLicenseemodifyObjectCreatormodifyBuyermodifyV15_4310 \ No newline at end of file diff --git a/mapp/src/test/resources/PackingManifest__Rank-10.xml b/mapp/src/test/resources/PackingManifest__Rank-10.xml new file mode 100644 index 0000000..31cfa9c --- /dev/null +++ b/mapp/src/test/resources/PackingManifest__Rank-10.xml @@ -0,0 +1 @@ +<__metadata>400$TypeExtensionD12103189452015-07-13 22:51:10.0842015-09-15 16:41:39.372Active45-14bc71f669bd4a984c69731b37f16f654https://commerce-preprod.gtnexus.com/en/trade/CustomObject?key=210318945$TypeExtensionD1210318945210318869PlatformModulePackingManifest310Active10225350053onActivateBuyeronPKMActivation4bc71f669bd4a984c69731b37f16f654 \ No newline at end of file diff --git a/mapp/src/test/resources/PlatformModule.xml b/mapp/src/test/resources/PlatformModule.xml new file mode 100644 index 0000000..9db8e7c --- /dev/null +++ b/mapp/src/test/resources/PlatformModule.xml @@ -0,0 +1,41 @@ + + <__metadata> + 400 + PlatformModule + 210318869 + 2015-07-13 22:50:59.766 + 2015-09-15 16:41:40.593 + Active + 56181b3ef3f602471bd3fb8c8d8b59bc + + 210318869 + 2015-07-13 22:50:59.766 + 2015-09-15 16:41:40.593 + -1 + Organization + 3717989018020186 + TradeCustomer + ParcelTracking + Master table modeling all parcel shipments + + + $ParcelTrackerS1 + STANDARD + + + $StagedTrackerS1 + STANDARD + + + ProofOfDelivery + + $ParcelTrackerS1 + 310 + OUTBOUNDINTEGRATION + + false + Buyer + + + 0.0.1 + \ No newline at end of file diff --git a/mapp/src/test/resources/datapoints.txt b/mapp/src/test/resources/datapoints.txt new file mode 100644 index 0000000..220026d --- /dev/null +++ b/mapp/src/test/resources/datapoints.txt @@ -0,0 +1,167 @@ +@DataPoint public static String[] adidas_BrandDescription = {"adidas", "BrandDescription"}; +@DataPoint public static String[] adidas_ConsolidatedShipments = {"adidas", "ConsolidatedShipments"}; +@DataPoint public static String[] adidas_CostPerCbm = {"adidas", "CostPerCbm"}; +@DataPoint public static String[] adidas_CustomerData = {"adidas", "CustomerData"}; +@DataPoint public static String[] adidas_InspectionApp = {"adidas", "InspectionApp"}; +@DataPoint public static String[] adidas_Integrated3pl = {"adidas", "Integrated3pl"}; +@DataPoint public static String[] adidas_LabelId = {"adidas", "LabelId"}; +@DataPoint public static String[] adidas_LocalLanguages = {"adidas", "LocalLanguages"}; +@DataPoint public static String[] adidas_OrderGroup = {"adidas", "OrderGroup"}; +@DataPoint public static String[] adidas_PaymentTermsDescription = {"adidas", "PaymentTermsDescription"}; +@DataPoint public static String[] adidas_PoaCriticalFields = {"adidas", "PoaCriticalFields"}; +@DataPoint public static String[] adidas_PortOfDischargeNonUs = {"adidas", "PortOfDischargeNonUs"}; +@DataPoint public static String[] adidas_PortOfDischargeUs = {"adidas", "PortOfDischargeUs"}; +@DataPoint public static String[] adidas_PortOfLoading = {"adidas", "PortOfLoading"}; +@DataPoint public static String[] adidas_ScanPackFields = {"adidas", "ScanPackFields"}; +@DataPoint public static String[] adidas_ShippingInstructions = {"adidas", "ShippingInstructions"}; +@DataPoint public static String[] adidas_ShippingOrderv2 = {"adidas", "ShippingOrderv2"}; +@DataPoint public static String[] adidas_Signatures = {"adidas", "Signatures"}; +@DataPoint public static String[] adidas_SportsDescription = {"adidas", "SportsDescription"}; +@DataPoint public static String[] adidas_TiCriticalFileds = {"adidas", "TiCriticalFileds"}; +@DataPoint public static String[] adidas_Tolerance = {"adidas", "Tolerance"}; +@DataPoint public static String[] adidas_Workflow = {"adidas", "Workflow"}; +@DataPoint public static String[] adidas_ZdocAmount = {"adidas", "ZdocAmount"}; +@DataPoint public static String[] adidas_customTableApp = {"adidas", "customTableApp"}; +@DataPoint public static String[] adidas_miadidasCSV = {"adidas", "miadidasCSV"}; +@DataPoint public static String[] anf_SellerExclusion = {"anf", "SellerExclusion"}; +@DataPoint public static String[] appXpressprovisioning_QCApp = {"appXpressprovisioning", "QCApp"}; +@DataPoint public static String[] appXpressprovisioning_docManagementApp = {"appXpressprovisioning", "docManagementApp"}; +@DataPoint public static String[] appXpressprovisioning_twoFieldRefTableForPickList = {"appXpressprovisioning", "twoFieldRefTableForPickList"}; +@DataPoint public static String[] bbg_BBGFirstSaleIPtypeExtensions = {"bbg", "BBGFirstSaleIPtypeExtensions"}; +@DataPoint public static String[] bbg_BBGFirstSaleTable = {"bbg", "BBGFirstSaleTable"}; +@DataPoint public static String[] bbg_BBGFirstSaleValidator = {"bbg", "BBGFirstSaleValidator"}; +@DataPoint public static String[] bbg_trackingtemplatescripts = {"bbg", "trackingtemplatescripts"}; +@DataPoint public static String[] brooksbrothers_BBGFirstSaleValidator = {"brooksbrothers", "BBGFirstSaleValidator"}; +@DataPoint public static String[] brookssports_BrooksSportsInvoiceValidations = {"brookssports", "BrooksSportsInvoiceValidations"}; +@DataPoint public static String[] coach_HKPaymentTable = {"coach", "HKPaymentTable"}; +@DataPoint public static String[] coach_NonUSPaymentDate = {"coach", "NonUSPaymentDate"}; +@DataPoint public static String[] coach_USPaymentDate = {"coach", "USPaymentDate"}; +@DataPoint public static String[] columbia_trackingtemplatescripts = {"columbia", "trackingtemplatescripts"}; +@DataPoint public static String[] converse_ConverseSapInvoiceLinker = {"converse", "ConverseSapInvoiceLinker"}; +@DataPoint public static String[] cortefiel_cortefiellandlord = {"cortefiel", "cortefiellandlord"}; +@DataPoint public static String[] cortefiel_LandlordRents = {"cortefiel", "LandlordRents"}; +@DataPoint public static String[] crocs_CrossDock = {"crocs", "CrossDock"}; +@DataPoint public static String[] crocs_FTerms = {"crocs", "FTerms"}; +@DataPoint public static String[] crocs_PoaCriticalFields = {"crocs", "PoaCriticalFields"}; +@DataPoint public static String[] crocs_trackingtemplatescripts = {"crocs", "trackingtemplatescripts"}; +@DataPoint public static String[] dbadim_FreightForwarder = {"dbadim", "FreightForwarder"}; +@DataPoint public static String[] dbadim_Incoterm = {"dbadim", "Incoterm"}; +@DataPoint public static String[] dbadim_LogisticServiceProvider = {"dbadim", "LogisticServiceProvider"}; +@DataPoint public static String[] dbadim_trackingtemplatescripts = {"dbadim", "trackingtemplatescripts"}; +@DataPoint public static String[] dbalovable_Incoterm = {"dbalovable", "Incoterm"}; +@DataPoint public static String[] dbalovable_LogisticServiceProvider = {"dbalovable", "LogisticServiceProvider"}; +@DataPoint public static String[] dbalovable_trackingtemplatescripts = {"dbalovable", "trackingtemplatescripts"}; +@DataPoint public static String[] deckers_CustomsBroker = {"deckers", "CustomsBroker"}; +@DataPoint public static String[] deckers_DeckersPrePayIPPadValidations = {"deckers", "DeckersPrePayIPPadValidations"}; +@DataPoint public static String[] deckers_DeckersPrePayIPPopulations = {"deckers", "DeckersPrePayIPPopulations"}; +@DataPoint public static String[] deckers_DeckersPrePayIPValidations = {"deckers", "DeckersPrePayIPValidations"}; +@DataPoint public static String[] deckers_PurchaseOrderPopulation = {"deckers", "PurchaseOrderPopulation"}; +@DataPoint public static String[] deckers_PurchaseOrderValidation = {"deckers", "PurchaseOrderValidation"}; +@DataPoint public static String[] deckers_TransitMatrix = {"deckers", "TransitMatrix"}; +@DataPoint public static String[] deckers_trackingtemplatescripts = {"deckers", "trackingtemplatescripts"}; +@DataPoint public static String[] dsg_DSGFirstSale = {"dsg", "DSGFirstSale"}; +@DataPoint public static String[] dsg_HangerRate = {"dsg", "HangerRate"}; +@DataPoint public static String[] dsg_ItemMarkUp = {"dsg", "ItemMarkUp"}; +@DataPoint public static String[] dsg_ManufacturerList = {"dsg", "ManufacturerList"}; +@DataPoint public static String[] dsg_MarkUp = {"dsg", "MarkUp"}; +@DataPoint public static String[] gap_BookingTerms = {"gap", "BookingTerms"}; +@DataPoint public static String[] gap_CustomsPackageModeler = {"gap", "CustomsPackageModeler"}; +@DataPoint public static String[] gap_HardTagPrices = {"gap", "HardTagPrices"}; +@DataPoint public static String[] gap_InvoiceAcknowledgements = {"gap", "InvoiceAcknowledgements"}; +@DataPoint public static String[] gap_ParcelTracking = {"gap", "ParcelTracking"}; +@DataPoint public static String[] gore_BuyReference = {"gore", "BuyReference"}; +@DataPoint public static String[] guesseurope_DeclarationOfIntentNumber = {"guesseurope", "DeclarationOfIntentNumber"}; +@DataPoint public static String[] guesseurope_Variance = {"guesseurope", "Variance"}; +@DataPoint public static String[] hurley_trackingtemplatescripts = {"hurley", "trackingtemplatescripts"}; +@DataPoint public static String[] internalpsoapplications_appXpressLogger = {"internalpsoapplications", "appXpressLogger"}; +@DataPoint public static String[] jcpenney_ContractMatching = {"jcpenney", "ContractMatching"}; +@DataPoint public static String[] jcpenney_EquipmentUtilityTable = {"jcpenney", "EquipmentUtilityTable"}; +@DataPoint public static String[] lampsplus_trackingtemplatescripts = {"lampsplus", "trackingtemplatescripts"}; +@DataPoint public static String[] luenthai_LuenThaiPurchaseOrderPopulationExtension = {"luenthai", "LuenThaiPurchaseOrderPopulationExtension"}; +@DataPoint public static String[] lululemon_MIDCodes = {"lululemon", "MIDCodes"}; +@DataPoint public static String[] lululemon_MIDCodes2 = {"lululemon", "MIDCodes2"}; +@DataPoint public static String[] lululemon_MIDCodesOLD = {"lululemon", "MIDCodesOLD"}; +@DataPoint public static String[] lululemon_VendorCodes = {"lululemon", "VendorCodes"}; +@DataPoint public static String[] lululemon_trackingtemplatescripts = {"lululemon", "trackingtemplatescripts"}; +@DataPoint public static String[] marcfisher_LeadTimeMatrix = {"marcfisher", "LeadTimeMatrix"}; +@DataPoint public static String[] microsoft_MicrosoftOrderExtensions = {"microsoft", "MicrosoftOrderExtensions"}; +@DataPoint public static String[] microsoft_MicrosoftPackingListValidations = {"microsoft", "MicrosoftPackingListValidations"}; +@DataPoint public static String[] microsoft_trackingtemplatescripts = {"microsoft", "trackingtemplatescripts"}; +@DataPoint public static String[] nike_EPPRestrictedFields = {"nike", "EPPRestrictedFields"}; +@DataPoint public static String[] nike_EPPRestrictedLookupTable = {"nike", "EPPRestrictedLookupTable"}; +@DataPoint public static String[] nike_INVCustomsData = {"nike", "INVCustomsData"}; +@DataPoint public static String[] nike_ItemScanningShipToCodeModule = {"nike", "ItemScanningShipToCodeModule"}; +@DataPoint public static String[] nike_ItemScanningVendorModule = {"nike", "ItemScanningVendorModule"}; +@DataPoint public static String[] nike_MarkForRelevant = {"nike", "MarkForRelevant"}; +@DataPoint public static String[] nike_certmodule746314099 = {"nike", "certmodule746314099"}; +@DataPoint public static String[] nike_shipToCode = {"nike", "shipToCode"}; +@DataPoint public static String[] oakley_trackingtemplatescripts = {"oakley", "trackingtemplatescripts"}; +@DataPoint public static String[] panpacific_AddressDetails = {"panpacific", "AddressDetails"}; +@DataPoint public static String[] patagonia_FirstSaleModule = {"patagonia", "FirstSaleModule"}; +@DataPoint public static String[] patagonia_trackingtemplatescripts = {"patagonia", "trackingtemplatescripts"}; +@DataPoint public static String[] pso_CriticalFieldsPlatform = {"pso", "CriticalFieldsPlatform"}; +@DataPoint public static String[] pso_InvoiceAcknowledgements = {"pso", "InvoiceAcknowledgements"}; +@DataPoint public static String[] pso_PartnerWarehouseTranslations = {"pso", "PartnerWarehouseTranslations"}; +@DataPoint public static String[] pso_PsoShippingOrder = {"pso", "PsoShippingOrder"}; +@DataPoint public static String[] pso_appXpressLogger = {"pso", "appXpressLogger"}; +@DataPoint public static String[] psoprovisioning_CriticalFieldsPlatform = {"psoprovisioning", "CriticalFieldsPlatform"}; +@DataPoint public static String[] psoprovisioning_InvoiceAcknowledgements = {"psoprovisioning", "InvoiceAcknowledgements"}; +@DataPoint public static String[] psoprovisioning_PsoShippingOrder = {"psoprovisioning", "PsoShippingOrder"}; +@DataPoint public static String[] psoprovisioning_appXpressLogger = {"psoprovisioning", "appXpressLogger"}; +@DataPoint public static String[] puma_IncotermLocationMapper = {"puma", "IncotermLocationMapper"}; +@DataPoint public static String[] puma_PODResponsiblePartyMapper = {"puma", "PODResponsiblePartyMapper"}; +@DataPoint public static String[] puma_PumaBookingResponse = {"puma", "PumaBookingResponse"}; +@DataPoint public static String[] puma_PumaInvoicePopulation = {"puma", "PumaInvoicePopulation"}; +@DataPoint public static String[] puma_PumaInvoicePopulations = {"puma", "PumaInvoicePopulations"}; +@DataPoint public static String[] puma_PumaInvoiceValidation = {"puma", "PumaInvoiceValidation"}; +@DataPoint public static String[] puma_PumaPADValidation = {"puma", "PumaPADValidation"}; +@DataPoint public static String[] puma_PumaPackingManifestValidation = {"puma", "PumaPackingManifestValidation"}; +@DataPoint public static String[] puma_PurchaseOrderPopulation = {"puma", "PurchaseOrderPopulation"}; +@DataPoint public static String[] puma_PurchaseOrderValidation = {"puma", "PurchaseOrderValidation"}; +@DataPoint public static String[] puma_trackingtemplatescripts = {"puma", "trackingtemplatescripts"}; +@DataPoint public static String[] pvh_PVHPackageBookingPopulation = {"pvh", "PVHPackageBookingPopulation"}; +@DataPoint public static String[] pvh_PVHPtsVldTypeExtension = {"pvh", "PVHPtsVldTypeExtension"}; +@DataPoint public static String[] ralphlauren_VcsErrorCodes = {"ralphlauren", "VcsErrorCodes"}; +@DataPoint public static String[] ralphlauren_VendorCategoryList = {"ralphlauren", "VendorCategoryList"}; +@DataPoint public static String[] ralphlauren_glCodeModule = {"ralphlauren", "glCodeModule"}; +@DataPoint public static String[] ralphlaurenjapan_PoloJapanHedging = {"ralphlaurenjapan", "PoloJapanHedging"}; +@DataPoint public static String[] riteaid_trackingtemplatescripts = {"riteaid", "trackingtemplatescripts"}; +@DataPoint public static String[] sole_trackingtemplatescripts = {"sole", "trackingtemplatescripts"}; +@DataPoint public static String[] stella_BuyerAgents = {"stella", "BuyerAgents"}; +@DataPoint public static String[] stella_TransitMatrix = {"stella", "TransitMatrix"}; +@DataPoint public static String[] stella_trackingtemplatescripts = {"stella", "trackingtemplatescripts"}; +@DataPoint public static String[] striderite_trackingtemplatescripts = {"striderite", "trackingtemplatescripts"}; +@DataPoint public static String[] targetaustralia_TargetAustraliaAddressTable = {"targetaustralia", "TargetAustraliaAddressTable"}; +@DataPoint public static String[] tcxgtnxintegration_GTNxEquipmentTypeCodes = {"tcxgtnxintegration", "GTNxEquipmentTypeCodes"}; +@DataPoint public static String[] thechildrensplace_PackingManifestValidation = {"thechildrensplace", "PackingManifestValidation"}; +@DataPoint public static String[] thechildrensplace_PurchaseOrderPopulation = {"thechildrensplace", "PurchaseOrderPopulation"}; +@DataPoint public static String[] thechildrensplace_PurchaseOrderValidation = {"thechildrensplace", "PurchaseOrderValidation"}; +@DataPoint public static String[] thechildrensplace_trackingtemplatescripts = {"thechildrensplace", "trackingtemplatescripts"}; +@DataPoint public static String[] topsondowns_trackingtemplatescripts = {"topsondowns", "trackingtemplatescripts"}; +@DataPoint public static String[] tradexpress_applicationAdviceModule = {"tradexpress", "applicationAdviceModule"}; +@DataPoint public static String[] tradexpress_infoMessageModule = {"tradexpress", "infoMessageModule"}; +@DataPoint public static String[] tradexpress_productActivityDataModule = {"tradexpress", "productActivityDataModule"}; +@DataPoint public static String[] tradexpress_remittanceAdviceModule = {"tradexpress", "remittanceAdviceModule"}; +@DataPoint public static String[] tristatetestbuyer_Harry201120test = {"tristatetestbuyer", "Harry201120test"}; +@DataPoint public static String[] tristatetestbuyer_MIN1 = {"tristatetestbuyer", "MIN1"}; +@DataPoint public static String[] tristatetestbuyer_ProdRegression2013Sep = {"tristatetestbuyer", "ProdRegression2013Sep"}; +@DataPoint public static String[] tristatetestbuyer_Regressionprod2013may = {"tristatetestbuyer", "Regressionprod2013may"}; +@DataPoint public static String[] tristatetestbuyer_Regressionprodfeb13 = {"tristatetestbuyer", "Regressionprodfeb13"}; +@DataPoint public static String[] tristatetestbuyer_jan2014 = {"tristatetestbuyer", "jan2014"}; +@DataPoint public static String[] tristatetestbuyer_managenewmodule = {"tristatetestbuyer", "managenewmodule"}; +@DataPoint public static String[] tristatetestbuyer_moduletest = {"tristatetestbuyer", "moduletest"}; +@DataPoint public static String[] tristatetestbuyer_nov2013prod = {"tristatetestbuyer", "nov2013prod"}; +@DataPoint public static String[] tristatetestbuyer_prodjan2014 = {"tristatetestbuyer", "prodjan2014"}; +@DataPoint public static String[] tristatetestbuyer_prodjuly2013 = {"tristatetestbuyer", "prodjuly2013"}; +@DataPoint public static String[] tristatetestbuyer_prodregression2014March = {"tristatetestbuyer", "prodregression2014March"}; +@DataPoint public static String[] walmart_WalmartPartyDetails = {"walmart", "WalmartPartyDetails"}; +@DataPoint public static String[] wolverine_PaymentDatesTable = {"wolverine", "PaymentDatesTable"}; +@DataPoint public static String[] wolverine_WiPPlannedDateLeadTime = {"wolverine", "WiPPlannedDateLeadTime"}; +@DataPoint public static String[] wolverine_WolverinePOCCustom = {"wolverine", "WolverinePOCCustom"}; +@DataPoint public static String[] wolverine_WolverinePOCInvoiceValidation = {"wolverine", "WolverinePOCInvoiceValidation"}; +@DataPoint public static String[] wolverine_trackingtemplatescripts = {"wolverine", "trackingtemplatescripts"}; +@DataPoint public static String[] wsi_WSIAgentCommisionTable = {"wsi", "WSIAgentCommisionTable"}; +@DataPoint public static String[] wsi_WSIDivisionNameTable = {"wsi", "WSIDivisionNameTable"}; +@DataPoint public static String[] wsi_WSIFinalDestinationCodeTable = {"wsi", "WSIFinalDestinationCodeTable"}; +@DataPoint public static String[] wsi_WSIOrderConfirmationStatusDocument = {"wsi", "WSIOrderConfirmationStatusDocument"}; +@DataPoint public static String[] wsi_trackingtemplatescripts = {"wsi", "trackingtemplatescripts"}; diff --git a/mapp/src/test/resources/mods_to_test b/mapp/src/test/resources/mods_to_test new file mode 100644 index 0000000..8156448 --- /dev/null +++ b/mapp/src/test/resources/mods_to_test @@ -0,0 +1,229 @@ +adidas +>BrandDescription +>ConsolidatedShipments +>CostPerCbm +>CustomerData +>InspectionApp +>Integrated3pl +>LabelId +>LocalLanguages +>OrderGroup +>PaymentTermsDescription +>PoaCriticalFields +>PortOfDischargeNonUs +>PortOfDischargeUs +>PortOfLoading +>ScanPackFields +>ShippingInstructions +>ShippingOrderv2 +>Signatures +>SportsDescription +>TiCriticalFileds +>Tolerance +>Workflow +>ZdocAmount +>customTableApp +>miadidasCSV +anf +>SellerExclusion +appXpressprovisioning +>QCApp +>docManagementApp +> twoFieldRefTableForPickList +bbg +>BBGFirstSaleIPtypeExtensions +>BBGFirstSaleTable +>BBGFirstSaleValidator +> trackingtemplatescripts +belk +brooksbrothers +>BBGFirstSaleValidator +brookssports +>BrooksSportsInvoiceValidations +cabelas +cbl +clarks +coach +>HKPaymentTable +>NonUSPaymentDate +> USPaymentDate +colehaan +columbia +> trackingtemplatescripts +converse +>ConverseSapInvoiceLinker +cortefiel +>cortefiellandlord +│   > LandlordRents +crocs +>CrossDock +>FTerms +>PoaCriticalFields +> trackingtemplatescripts +dbadim +>FreightForwarder +>Incoterm +>LogisticServiceProvider +> trackingtemplatescripts +dbalovable +>Incoterm +>LogisticServiceProvider +> trackingtemplatescripts +dcshoes +deckers +>CustomsBroker +>DeckersPrePayIPPadValidations +>DeckersPrePayIPPopulations +>DeckersPrePayIPValidations +>PurchaseOrderPopulation +>PurchaseOrderValidation +>TransitMatrix +> trackingtemplatescripts +dsg +>DSGFirstSale +>HangerRate +>ItemMarkUp +>ManufacturerList +>MarkUp +gap +>BookingTerms +>CustomsPackageModeler +>HardTagPrices +>InvoiceAcknowledgements +>ParcelTracking +gore +> BuyReference +guess +guesseurope +>DeclarationOfIntentNumber +>Variance +hurley +> trackingtemplatescripts +internalpsoapplications +> appXpressLogger +jcpenney +>ContractMatching +>EquipmentUtilityTable +lampsplus +> trackingtemplatescripts +lanebryant +levis +luenthai +> LuenThaiPurchaseOrderPopulationExtension +lululemon +>MIDCodes +>MIDCodes2 +>MIDCodesOLD +>VendorCodes +> trackingtemplatescripts +macys +marcfisher +>LeadTimeMatrix +microsoft +>MicrosoftOrderExtensions +>MicrosoftPackingListValidations +> trackingtemplatescripts +nike +>EPPRestrictedFields +>EPPRestrictedLookupTable +>INVCustomsData +>ItemScanningShipToCodeModule +>ItemScanningVendorModule +>MarkForRelevant +>certmodule746314099 +> shipToCode +oakley +> trackingtemplatescripts +offbroadway +oneill +panpacific +> AddressDetails +patagonia +>FirstSaleModule +> trackingtemplatescripts +pso +>CriticalFieldsPlatform +>InvoiceAcknowledgements +>PartnerWarehouseTranslations +>PsoShippingOrder +> appXpressLogger +psoprovisioning +>CriticalFieldsPlatform +>InvoiceAcknowledgements +>PsoShippingOrder +> appXpressLogger +puma +>IncotermLocationMapper +>PODResponsiblePartyMapper +>PumaBookingResponse +>PumaInvoicePopulation +>PumaInvoicePopulations +>PumaInvoiceValidation +>PumaPADValidation +>PumaPackingManifestValidation +>PurchaseOrderPopulation +>PurchaseOrderValidation +> trackingtemplatescripts +pvh +>PVHPackageBookingPopulation +>PVHPtsVldTypeExtension +ralphlauren +>VcsErrorCodes +>VendorCategoryList +>glCodeModule +ralphlaurenjapan +>PoloJapanHedging +rei +riteaid +> trackingtemplatescripts +sole +> trackingtemplatescripts +stella +>BuyerAgents +>TransitMatrix +> trackingtemplatescripts +striderite +> trackingtemplatescripts +targetaustralia +>TargetAustraliaAddressTable +tcxgtnxintegration +> GTNxEquipmentTypeCodes +thechildrensplace +>PackingManifestValidation +>PurchaseOrderPopulation +>PurchaseOrderValidation +> trackingtemplatescripts +topsondowns +> trackingtemplatescripts +tradexpress +>applicationAdviceModule +>infoMessageModule +>productActivityDataModule +> remittanceAdviceModule +tristatetestbuyer +>Harry201120test +>MIN1 +>ProdRegression2013Sep +>Regressionprod2013may +>Regressionprodfeb13 +>jan2014 +>managenewmodule +>moduletest +>nov2013prod +>prodjan2014 +>prodjuly2013 +> prodregression2014March +walmart +> WalmartPartyDetails +wolverine +>PaymentDatesTable +>WiPPlannedDateLeadTime +>WolverinePOCCustom +>WolverinePOCInvoiceValidation +> trackingtemplatescripts +wsi +>WSIAgentCommisionTable +>WSIDivisionNameTable +>WSIFinalDestinationCodeTable +>WSIOrderConfirmationStatusDocument +> trackingtemplatescripts diff --git a/mapp/src/test/resources/tree_to_data_points.py b/mapp/src/test/resources/tree_to_data_points.py new file mode 100644 index 0000000..994294e --- /dev/null +++ b/mapp/src/test/resources/tree_to_data_points.py @@ -0,0 +1,18 @@ +import re + +f = open('mods_to_test', 'r') +datapoints = [] +customer="_DEAD_" +module="" +for line in f: + match = re.search(">", line) + if match: + module = line.split('>').pop().strip() + datapoints.append((customer, module)) + else: + customer=line.strip() +target = open("datapoints.txt", "w") +for point in datapoints: + point_string = "@DataPoint public static String[] " + point[0] + "_" + point[1] + " = {\"" + point[0]+ "\", \"" + point[1] + "\"};\n" + target.write(point_string) + diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..de1f96c --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'PlatformModuleManager' +include 'mapi', 'mapp' diff --git a/src/main/java/com/gtnexus/appxpress/PlatformModuleManager.java b/src/main/java/com/gtnexus/appxpress/PlatformModuleManager.java deleted file mode 100644 index 03da94d..0000000 --- a/src/main/java/com/gtnexus/appxpress/PlatformModuleManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.gtnexus.appxpress; - -import java.util.Set; - -import com.gtnexus.appxpress.cli.command.CLICommand; -import com.gtnexus.appxpress.cli.command.CommandParser; -import com.gtnexus.appxpress.commons.command.Command; -import com.gtnexus.appxpress.exception.AppXpressException; - -public class PlatformModuleManager { - - public static void main(String... args) { - new PlatformModuleManager().run(args); - } - - public PlatformModuleManager() { - } - - protected void run(String... args) { - try { - PlatformModuleManager.getCommand(this, args).execute(); - } catch (AppXpressException e) { - System.out.println(e.getAppXpressMessage()); - } - } - - public static Command getCommand(PlatformModuleManager pmm, String... args) { - return new CommandParser(pmm.getCommands()).parse(args) - .or(PlatformModuleManagerCommand.HELP.constructCommand(args)); - } - - public Set getCommands() { - return PlatformModuleManagerCommand.getAllCommands(); - } -} diff --git a/src/main/java/com/gtnexus/appxpress/PlatformModuleManagerCommand.java b/src/main/java/com/gtnexus/appxpress/PlatformModuleManagerCommand.java deleted file mode 100644 index c91dcfe..0000000 --- a/src/main/java/com/gtnexus/appxpress/PlatformModuleManagerCommand.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.gtnexus.appxpress; - -import java.util.Set; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.gtnexus.appxpress.cli.command.CLICommand; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; -import com.gtnexus.appxpress.commons.command.Command; -import com.gtnexus.appxpress.pmbuilder.BuildCommand; -import com.gtnexus.appxpress.pmdocgen.PMDocGenCommand; -import com.gtnexus.appxpress.pmextractor.ExtractCommand; - -public abstract class PlatformModuleManagerCommand implements CLICommand { - - /** - * - */ - public static final PlatformModuleManagerCommand HELP = new PlatformModuleManagerCommand() { - - @Override - public String getName() { - return "help"; - } - - @Override - public String getFlag() { - return "h"; - } - - @Override - public String getDescription() { - return "displays this message"; - } - - @Override - public boolean isHelpFlag() { - return true; - } - - @Override - public Command constructCommand(String... args) { - return new Command() { - private final String blurb = Joiner.on("\n") - .join(Iterables.transform(ALL_COMMANDS, new Function() { - @Override - public String apply(CLICommand cmd) { - StringBuilder b = new StringBuilder(); - b.append(cmd.getName()); - if (cmd.getFlag() != null) { - b.append(" (-").append(cmd.getFlag()).append(")"); - } else { - b.append("\t"); - } - b.append("\t").append(cmd.getDescription()); - return b.toString(); - } - })); - - private final String template = "Welcome to the AppXpress Platform Module Manager\n\n%s"; - - @Override - public void execute() { - System.out.println(String.format(template, blurb)); - System.exit(0); - } - - }; - } - }; - - /** - * - */ - public static final PlatformModuleManagerCommand BUILD = new PlatformModuleManagerCommand() { - - @Override - public String getName() { - return "build"; - } - - @Override - public String getDescription() { - return "runs the platform module builder tool. for more information please run pmm build -h"; - } - - @Override - public Command constructCommand(String... args) { - return new BuildCommand(args); - } - - }; - - /** - * - */ - public static final PlatformModuleManagerCommand EXTRACT = new PlatformModuleManagerCommand() { - - @Override - public String getName() { - return "extract"; - } - - @Override - public String getDescription() { - return "runs the platform module extractor tool. for more information please run pmm extract -h"; - } - - @Override - public Command constructCommand(String... args) { - return new ExtractCommand(args); - } - - }; - - public static final PlatformModuleManagerCommand DOCGEN = new PlatformModuleManagerCommand() { - - @Override - public String getName() { - return "docgen"; - } - - @Override - public String getDescription() { - return "generates docs/specs for a given platform module"; - } - - @Override - public Command constructCommand(String... args) { - return new PMDocGenCommand(args); - } - }; - - private static final Set ALL_COMMANDS = new ImmutableSet.Builder().add(HELP).add(EXTRACT) - .add(BUILD).add(DOCGEN).build(); - - private static final OptionMessageProvider msgProvider = new OptionMessageProvider(); - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getFlag() { - return null; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(Command.class, this.getName()); - } - - public static Set getAllCommands() { - return ALL_COMMANDS; - } -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/CLIOptsAndPropConsolidator.java b/src/main/java/com/gtnexus/appxpress/cli/CLIOptsAndPropConsolidator.java deleted file mode 100644 index dfd18f5..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/CLIOptsAndPropConsolidator.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.gtnexus.appxpress.cli; - -import java.io.InputStream; -import java.io.PrintStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import com.gtnexus.appxpress.cli.asker.Asker; -import com.gtnexus.appxpress.cli.asker.SimpleAsker; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.properties.PMProperties; - -/** - * Consolidates stored properties file from User, with flags passed from CLI. - *

- * Flags passed from the CLI take precedence over what is stored in the - * properties file. If neither is present for a mandatory ExtractorOption, then - * the user is prompted for input. - * - * @author jjdonov - */ -public class CLIOptsAndPropConsolidator { - - private final Map userArgs; - private final Set optSet; - private final PMProperties properties; - private final SimpleAsker asker; - - /** - * - * @param userArgs - * Arguments passed from the CLI. - * @param optSet - * @param properties - * Properties file read from user's AppXpress directory. - */ - public CLIOptsAndPropConsolidator(Map userArgs, Set optSet, PMProperties properties) { - this.userArgs = userArgs; - this.optSet = optSet; - this.properties = properties; - this.asker = new SimpleAsker(System.in, System.out); - } - - /** - * @param userArgs - * Arguments passed from the CLI. - * @param properties - * Properties file read from user's AppXpress directory. - * @param inputStream - * The input stream that this consolidator should read from. - * @param printStream - * The printStream that this consolidator should write to. - */ - public CLIOptsAndPropConsolidator(Map userArgs, Set optSet, PMProperties properties, - InputStream inputStream, PrintStream printStream) { - this.userArgs = userArgs; - this.optSet = optSet; - this.properties = properties; - this.asker = new SimpleAsker(inputStream, printStream); - } - - /** - * @return the map of consolidated ExtractorOptions and their values. - */ - public Map consolidate() { - final Map optMap = new HashMap<>(); - for (T opt : optSet) { - if (!opt.shouldBeOmitted()) { - String val = consolidateSingle(opt); - optMap.put(opt, val); - } - } - return optMap; - } - - /** - * - * @param option - * the option we are consolidating - * @return the consolidated result - */ - private String consolidateSingle(CLICommandOption option) { - String input = null; - String propVal = null; - if (option.isStoreableProperty()) { - propVal = properties.getProperty(option.getLongName()); - } - if (userArgs.containsKey(option)) { - input = userArgs.get(option); - storeIfAppropriate(option, input); - return input; - } else if (propVal != null && !propVal.isEmpty()) { - return propVal; - } else if (option.isAppXpressMandatory()) { - input = getParameterFromUser(option); - storeIfAppropriate(option, input); - return input; - } else { - return option.getDefaultValue(); - } - } - - private void storeIfAppropriate(CLICommandOption option, String input) { - if (option.isStoreableProperty()) { - properties.put(option.getLongName(), input); - } - } - - /** - * @param option - * The ExtractorOption to be query the user for. - * @return The value entered by the user. - */ - private String getParameterFromUser(CLICommandOption option) { - String val = asker.ask(option.getMessage()); - while (!option.isValid(val)) { - val = asker.ask(Asker.INVALID_INPUT); - } - return val; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/IntegerAsker.java b/src/main/java/com/gtnexus/appxpress/cli/asker/IntegerAsker.java deleted file mode 100644 index 799892b..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/IntegerAsker.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gtnexus.appxpress.cli.asker; - -import java.io.InputStream; -import java.io.PrintStream; - -public class IntegerAsker extends SimpleTypedAsker { - - public IntegerAsker(InputStream in, PrintStream out) { - super(in, out); - } - - public IntegerAsker(SimpleAsker asker) { - super(asker); - } - - @Override - protected Integer convert(String m) { - Integer r = null; - try { - r = Integer.valueOf(m); - } catch (NumberFormatException e) { - } - return r; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/SimpleTypedAsker.java b/src/main/java/com/gtnexus/appxpress/cli/asker/SimpleTypedAsker.java deleted file mode 100644 index 9468686..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/SimpleTypedAsker.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gtnexus.appxpress.cli.asker; - -import java.io.InputStream; -import java.io.PrintStream; - -public abstract class SimpleTypedAsker implements Asker { - - private SimpleAsker asker; - - public SimpleTypedAsker(InputStream in, PrintStream out) { - this.asker = new SimpleAsker(in, out); - } - - public SimpleTypedAsker(SimpleAsker asker) { - this.asker = asker; - } - - @Override - public T ask(String message) { - String result = asker.ask(message); - return convert(result); - } - - protected abstract T convert(String m); - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/asker/ValidityProvider.java b/src/main/java/com/gtnexus/appxpress/cli/asker/ValidityProvider.java deleted file mode 100644 index 1f4a565..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/asker/ValidityProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.gtnexus.appxpress.cli.asker; - -public class ValidityProvider { - - public boolean isValid(String val, Class type) { - if (val == null || val.length() == 0) { - return false; - } - if (type.equals(String.class)) { - return true; - } - if (type.equals(Integer.class)) { - return val.matches("\\d+"); - } else if (type.equals(Boolean.class)) { - return val.equalsIgnoreCase("Y") || val.equalsIgnoreCase("N"); - } else { - return false; - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/command/CLICommand.java b/src/main/java/com/gtnexus/appxpress/cli/command/CLICommand.java deleted file mode 100644 index 43171b1..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/command/CLICommand.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gtnexus.appxpress.cli.command; - -import com.gtnexus.appxpress.commons.command.Command; - -public interface CLICommand { - public String getName(); - - public boolean isHelpFlag(); - - public String getDescription(); - - public String getFlag(); - - public String getMessage(); - - public Command constructCommand(String... args); -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/command/CommandParser.java b/src/main/java/com/gtnexus/appxpress/cli/command/CommandParser.java deleted file mode 100644 index 0749e47..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/command/CommandParser.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.gtnexus.appxpress.cli.command; - -import java.util.Arrays; -import java.util.Set; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.gtnexus.appxpress.commons.command.Command; - -public class CommandParser { - - private final Set commands; - - public CommandParser(Set commands) { - Preconditions.checkNotNull(commands); - Preconditions.checkArgument(commands.size() > 0); - this.commands = commands; - } - - // we assume the first argument is either a valid command or a help flag - public Optional parse(String... args) { - if (args.length == 0) { - return Optional.absent(); - } - String cmd = args[0]; - String[] childArgs = restOf(args); - for (CLICommand command : commands) { - if (isNameOrFlagMatch(command, cmd)) { - return Optional.fromNullable(command.constructCommand(childArgs)); - } - } - System.out.println("Not a recognized command" + cmd); - return Optional.absent(); - } - - private boolean isNameOrFlagMatch(CLICommand command, String cmd) { - if (command.getName().equals(cmd)) { - return true; - } - if (command.getFlag() != null && cmd.startsWith("-")) { - if (command.getFlag().equals(cmd.substring(1, cmd.length()))) { - return true; - } - } - return false; - } - - private String[] restOf(String... args) { - if (args.length < 2) { - return new String[0]; - } - return Arrays.copyOfRange(args, 1, args.length); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOption.java b/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOption.java deleted file mode 100644 index 9a11816..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOption.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -/** - * Extension of typical command line options interface. Holds AppXpress specific - * logic. - * - * @author jdonovan - * - */ -public interface CLICommandOption extends CLIOption { - - public String getMessage(); - - public boolean isAppXpressMandatory(); - - public boolean shouldBeOmitted(); - - public boolean isValid(String val); - - public String getDefaultValue(); - - public boolean isStoreableProperty(); - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOptionInterpreter.java b/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOptionInterpreter.java deleted file mode 100644 index 21c7a64..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/CLICommandOptionInterpreter.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Map; - -import org.apache.commons.cli.HelpFormatter; - -import com.gtnexus.appxpress.cli.CLIOptsAndPropConsolidator; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; - -public abstract class CLICommandOptionInterpreter implements CLIOptionInterpreter { - - private ParsedOptions parsedOptions; - private final PMMCommandInfo app; - protected final SimpleShutdown shutdown; - protected final PMProperties properties; - - public CLICommandOptionInterpreter(PMMCommandInfo app, SimpleShutdown shutdown, ParsedOptions parsedOptions, - PMProperties properties) { - this.app = app; - this.shutdown = shutdown; - this.parsedOptions = parsedOptions; - this.properties = properties; - } - - @Override - public final Map interpret() throws AppXpressException { - if (parsedOptions.isHelpFlagSet()) { - HelpFormatter helpFormatter = new HelpFormatter(); - helpFormatter.printHelp(app.getName(), app.getHelpHeader(), parsedOptions.getOptions(), - app.getHelpFooter()); - shutdown.shutdown(); - } - parsedOptions = performCustomInterpretation(parsedOptions); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(parsedOptions.getOptionsMap(), - parsedOptions.getCliOptionSet(), properties); - Map optMap = consolidator.consolidate(); - return optMap; - } - - protected boolean isCustomerFolder(Path dir, T localDirKey) throws AppXpressException { - final String localDir = resolveLocalDir(localDirKey); - if (localDir == null || localDir.isEmpty()) { - throw new AppXpressException("Local Directory property is not set. " - + "Please check your AppXpress properties file" + "before trying to run the Select option again."); - } - Path parent = dir.getParent(); - Path ld = Paths.get(localDir); - if (parent.equals(ld)) { - return true; - } - return false; - } - - private String resolveLocalDir(T localDirKey) { - if (parsedOptions.hasOption(localDirKey)) { - return parsedOptions.getOption(localDirKey); - } - return properties.getProperty(localDirKey); - } - - protected abstract ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) - throws AppXpressException; - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOption.java b/src/main/java/com/gtnexus/appxpress/cli/option/CLIOption.java deleted file mode 100644 index d5f916f..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOption.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -public interface CLIOption { - @Override - public String toString(); - - public String getLongName(); - - public String getFlag(); - - public Class getType(); - - public String getDescription(); - - public boolean hasArg(); - - public boolean isHelpFlag(); -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionInterpreter.java b/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionInterpreter.java deleted file mode 100644 index bd84ec4..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionInterpreter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import java.util.Map; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public interface CLIOptionInterpreter { - - public Map interpret() throws AppXpressException; - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionParser.java b/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionParser.java deleted file mode 100644 index 78bb103..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/CLIOptionParser.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import java.util.Set; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; - -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.exception.PMExtractorException; - -/** - * Wrapper to tie together CLIOptions and the Apache Commons CLI library. - * - * @author jdonovan - * - */ -public class CLIOptionParser { - - private final String[] userArgs; - private final Set cliOptionSet; - private final Options options; - private CommandLine cmd; - - public static CLIOptionParser createParser(Set cliOptSet, String[] userArgs) { - Options options = new Options(); - for (CLIOption opt : cliOptSet) { - options.addOption(Option.builder(opt.getFlag()).longOpt(opt.getLongName()).type(opt.getType()) - .desc(opt.getDescription()).hasArg(opt.hasArg()).required(false).build()); - } - return new CLIOptionParser<>(userArgs, cliOptSet, options); - } - - /** - * - * @param userArgs - * the args provided to main() by the user when invoking this tool - * @param cliOptionSet - * the option set defining what can be passed to this tool - */ - public CLIOptionParser(String[] userArgs, Set cliOptionSet, Options options) { - if (userArgs == null || cliOptionSet == null) { - throw new NullPointerException("Cannot parse null args, or null option set."); - } - this.userArgs = userArgs; - this.cliOptionSet = cliOptionSet; - this.options = options; - } - - /** - * Parses the args provided by the user according to the provided option set. - * - * @throws PMExtractorException - * if input is not parasable. - */ - public ParsedOptions parse() throws AppXpressException { - CommandLineParser parser = new DefaultParser(); - try { - cmd = parser.parse(options, userArgs); - } catch (ParseException e) { - throw new PMExtractorException("Failed to parse args from command line!\n" + e.getMessage()); - } - return ParsedOptions.createFrom(this); - } - - public CommandLine getCommandLine() { - return cmd; - } - - public Set getCliOptionSet() { - return cliOptionSet; - } - - public Options getOptions() { - return options; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/OptionMessageProvider.java b/src/main/java/com/gtnexus/appxpress/cli/option/OptionMessageProvider.java deleted file mode 100644 index 5dd2d5c..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/OptionMessageProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import com.gtnexus.appxpress.commons.command.Command; - -public class OptionMessageProvider { - - public String getMessage(Class type, String name) { - if (type.equals(Command.class)) { - return "Please enter a valid command."; - } else if (type.equals(Integer.class)) { - return ("Please enter the number of " + name + "(s): "); - } else if (type.equals(String.class)) { - return ("Please enter " + name + ": "); - } else if (type.equals(Boolean.class)) { - return ("Do you want " + name + "? [y/n]: "); - } - throw new RuntimeException("ExtractorOption type" + type.toString() + " is unsupported"); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/ParsedOptions.java b/src/main/java/com/gtnexus/appxpress/cli/option/ParsedOptions.java deleted file mode 100644 index 81a46da..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/ParsedOptions.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import java.io.File; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Options; - -import com.google.common.base.Preconditions; - -public class ParsedOptions { - - public static ParsedOptions createFrom(CLIOptionParser parser) { - return createFrom(parser.getCommandLine(), parser.getOptions(), parser.getCliOptionSet()); - } - - public static ParsedOptions createFrom(CommandLine cmd, Options options, Set optSet) { - Preconditions.checkNotNull(cmd); - Preconditions.checkNotNull(options); - Preconditions.checkNotNull(optSet); - Map optMap; - boolean helpFlagIsSet = false; - optMap = new HashMap<>(); - for (M opt : optSet) { - if (cmd.hasOption(opt.getLongName()) || cmd.hasOption(opt.getFlag())) { - optMap.put(opt, cmd.getOptionValue(opt.getLongName())); - if (opt.isHelpFlag()) { - helpFlagIsSet = true; - } - } - } - return new ParsedOptions(options, optMap, helpFlagIsSet, optSet); - } - - // --------------------------------------------------------------------------------------------- - - private final Options options; - private final Map optionsMap; - private final boolean helpFlagIsSet; - private final Set optSet; - - public ParsedOptions(Options options, Map optionsMap, Set optSet) { - this(options, optionsMap, false, optSet); - } - - public ParsedOptions(Options options, Map optionsMap, boolean helpFlagIsSet, Set optSet) { - this.options = options; - this.optionsMap = optionsMap; - this.helpFlagIsSet = helpFlagIsSet; - this.optSet = optSet; - } - - public Map getOptionsMap() { - return optionsMap; - } - - public Options getOptions() { - return options; - } - - /** - * Checks to see if the user provided this CLIOption. - * - * @param opt - * the CLIOption being checked for. - * @return false if parsing has not yet been performed. - */ - public boolean hasOption(T opt) { - return optionsMap.containsKey(opt); - } - - public String getOption(T opt) { - return optionsMap.get(opt); - } - - public Set getCliOptionSet() { - return optSet; - } - - /** - * - * @return whether or not the parsed parameters contain the help flag - */ - public boolean isHelpFlagSet() { - return helpFlagIsSet; - } - - public void put(T opt, String val) { - optionsMap.put(opt, val); - } - - public void put(T opt, Path val) { - put(opt, val.getFileName().toString()); - } - - public void put(T opt, File val) { - put(opt, val.getName()); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/options/CustomerOption.java b/src/main/java/com/gtnexus/appxpress/cli/option/options/CustomerOption.java deleted file mode 100644 index dac01bd..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/options/CustomerOption.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gtnexus.appxpress.cli.option.options; - -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -public class CustomerOption implements CLICommandOption { - - private final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private final ValidityProvider validityProvider = new ValidityProvider(); - - @Override - public String getLongName() { - return "customer"; - } - - @Override - public String getFlag() { - return "c"; - } - - @Override - public Class getType() { - return String.class; - } - - @Override - public String getDescription() { - return "The customer who owns this module"; - } - - @Override - public boolean hasArg() { - return true; - } - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(this.getType(), this.getLongName()); - } - - @Override - public boolean isAppXpressMandatory() { - return true; - } - - @Override - public boolean shouldBeOmitted() { - return false; - } - - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, this.getType()); - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/options/HelpOpt.java b/src/main/java/com/gtnexus/appxpress/cli/option/options/HelpOpt.java deleted file mode 100644 index 0e8bd3a..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/options/HelpOpt.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.gtnexus.appxpress.cli.option.options; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; - -public class HelpOpt implements CLICommandOption { - - @Override - public String getLongName() { - return "help"; - } - - @Override - public String getFlag() { - return "h"; - } - - @Override - public Class getType() { - return String.class; - } - - @Override - public String getDescription() { - return "Display usage for this tool"; - } - - @Override - public boolean hasArg() { - return false; - } - - @Override - public boolean isHelpFlag() { - return true; - } - - @Override - public String getMessage() { - return "we have no msg :("; - } - - @Override - public boolean isAppXpressMandatory() { - return false; - } - - @Override - public boolean shouldBeOmitted() { - return true; - } - - @Override - public boolean isValid(String val) { - return true; - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/options/LocalDirOpt.java b/src/main/java/com/gtnexus/appxpress/cli/option/options/LocalDirOpt.java deleted file mode 100644 index 7a6644b..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/options/LocalDirOpt.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gtnexus.appxpress.cli.option.options; - -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -public class LocalDirOpt implements CLICommandOption { - - private final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private final ValidityProvider validityProvider = new ValidityProvider(); - - @Override - public String getLongName() { - return "localDir"; - } - - @Override - public String getFlag() { - return "ld"; - } - - @Override - public Class getType() { - return String.class; - } - - @Override - public String getDescription() { - return "Relative path of git staging folder."; - } - - @Override - public boolean hasArg() { - return true; - } - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(this.getType(), this.getLongName()); - } - - @Override - public boolean isAppXpressMandatory() { - return true; - } - - @Override - public boolean shouldBeOmitted() { - return false; - } - - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, this.getType()); - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return true; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/options/ModuleOption.java b/src/main/java/com/gtnexus/appxpress/cli/option/options/ModuleOption.java deleted file mode 100644 index 493c310..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/options/ModuleOption.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gtnexus.appxpress.cli.option.options; - -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -public class ModuleOption implements CLICommandOption { - - private final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private final ValidityProvider validityProvider = new ValidityProvider(); - - @Override - public String getLongName() { - return "module"; - } - - @Override - public String getFlag() { - return "m"; - } - - @Override - public Class getType() { - return String.class; - } - - @Override - public String getDescription() { - return "The name of the module"; - } - - @Override - public boolean hasArg() { - return true; - } - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(this.getType(), this.getLongName()); - } - - @Override - public boolean isAppXpressMandatory() { - return true; - } - - @Override - public boolean shouldBeOmitted() { - return false; - } - - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, this.getType()); - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/cli/option/options/SelectOption.java b/src/main/java/com/gtnexus/appxpress/cli/option/options/SelectOption.java deleted file mode 100644 index 171fb8f..0000000 --- a/src/main/java/com/gtnexus/appxpress/cli/option/options/SelectOption.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gtnexus.appxpress.cli.option.options; - -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -public class SelectOption implements CLICommandOption { - - private final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private final ValidityProvider validityProvider = new ValidityProvider(); - - @Override - public String getLongName() { - return "select"; - } - - @Override - public String getFlag() { - return "s"; - } - - @Override - public Class getType() { - return Integer.class; - } - - @Override - public String getDescription() { - return "Select module from the folders present in the cwd."; - } - - @Override - public boolean hasArg() { - return false; - } - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(this.getType(), this.getLongName()); - } - - @Override - public boolean isAppXpressMandatory() { - return false; - } - - @Override - public boolean shouldBeOmitted() { - return true; - } - - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, this.getType()); - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/HasPrerequisite.java b/src/main/java/com/gtnexus/appxpress/commons/HasPrerequisite.java deleted file mode 100644 index 660c152..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/HasPrerequisite.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.gtnexus.appxpress.commons; - -public interface HasPrerequisite { - public boolean isMet(T obj); - - public class EmptyCondition implements HasPrerequisite { - - @Override - public boolean isMet(Y obj) { - return true; - } - - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/Mapper.java b/src/main/java/com/gtnexus/appxpress/commons/Mapper.java deleted file mode 100644 index d88c508..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/Mapper.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gtnexus.appxpress.commons; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public interface Mapper { - - public void doMapping() throws AppXpressException; - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/Preparation.java b/src/main/java/com/gtnexus/appxpress/commons/Preparation.java deleted file mode 100644 index e7bd1bf..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/Preparation.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gtnexus.appxpress.commons; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public interface Preparation { - - public void prepare(T t) throws AppXpressException; - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/command/Command.java b/src/main/java/com/gtnexus/appxpress/commons/command/Command.java deleted file mode 100644 index c1fbb4f..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/command/Command.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.gtnexus.appxpress.commons.command; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public interface Command { - public void execute() throws AppXpressException; -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/command/PMMCommandInfo.java b/src/main/java/com/gtnexus/appxpress/commons/command/PMMCommandInfo.java deleted file mode 100644 index b447dc5..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/command/PMMCommandInfo.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.gtnexus.appxpress.commons.command; - -import java.util.Set; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; - -public interface PMMCommandInfo { - - public String getName(); - - public String getHelpHeader(); - - public String getHelpFooter(); - - public Class getContextType(); - - public Set getOptions(); - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/FileService.java b/src/main/java/com/gtnexus/appxpress/commons/file/FileService.java deleted file mode 100644 index 851237c..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/file/FileService.java +++ /dev/null @@ -1,300 +0,0 @@ -package com.gtnexus.appxpress.commons.file; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import com.google.common.base.Preconditions; -import com.gtnexus.appxpress.commons.HasPrerequisite; - -/** - * Service class to handle File IO procedures common to app. - * - * @author jdonovan - * - */ -public class FileService { - - /** - * Prepends a String to the front of a single file. - * - * @param file - * The file whose name will be altered. - * @param prepend - * The String to prepend to the file's name. - */ - public Path prependToName(File file, String prepend) throws IOException { - return renameFile(file, prepend + file.getName()); - } - - public Path prependToName(File file, String prepend, HasPrerequisite precondition) throws IOException { - return renameFile(file, prepend + file.getName(), precondition); - } - - /** - * Prepends a String to the the names of a collection of a files. - * - * @param files - * The list of files who's name will be altered. - * @param prepend - * The String to prepend to each file name. - */ - public List prependToName(Collection files, String prepend) throws IOException { - return prependToName(files, prepend, new HasPrerequisite.EmptyCondition()); - } - - /** - * Prepends a String to the the names of a collection of a files. - * - * @param files - * The list of files who's name will be altered. - * @param prepend - * The String to prepend to each file name. - * @precondition The condition that must be met before string is prepended to - * file name - */ - public List prependToName(Collection files, String prepend, HasPrerequisite precondition) - throws IOException { - List paths = new LinkedList<>(); - for (File file : files) { - paths.add(prependToName(file, prepend, precondition)); - } - return paths; - } - - /** - * Rename a single file - * - * @param file - * The file whose name will be altered. - * @param newName - * The files new name. - * @throws IOException - * if the renaming operation fails. - */ - public Path renameFile(File file, String newName) throws IOException { - return renameFile(file, newName, new HasPrerequisite.EmptyCondition()); - } - - /** - * Rename a single file - * - * @param file - * The file whose name will be altered. - * @param newName - * The files new name. - * @throws IOException - * if the renaming operation fails. - */ - public Path renameFile(File file, String newName, HasPrerequisite precondition) throws IOException { - Path path = file.toPath(); - if (!precondition.isMet(file)) - return path; - try { - path = Files.move(file.toPath(), file.toPath().resolveSibling(newName)); - } catch (IOException e) { - throw new IOException("Exception when trying to rename " + file.getAbsolutePath(), e); - } - return path; - } - - /** - * Renames a set of files by replacing a matched string with some replacement. - * - * @param files - * The set of file's whose names will be altered if they match the - * replacement string. - * @param toReplace - * The string that will be replaced if found in any file names. - * @param replacement - * The string that will replace the found string in the file name. - */ - public List renameFile(Collection files, String toReplace, String replacement) throws IOException { - return renameFile(files, toReplace, replacement, new HasPrerequisite.EmptyCondition()); - } - - /** - * Renames a set of files by replacing a matched string with some replacement as - * long as some precondition is met for each file. - * - * @param files - * The set of file's whose names will be altered if they match the - * replacement string. - * @param toReplace - * The string that will be replaced if found in any file names. - * @param replacement - * The string that will replace the found string in the file name. - * @param precondition - * The precondition that must be met in order for file to be renamed. - */ - public List renameFile(Collection files, String toReplace, String replacement, - HasPrerequisite precondition) throws IOException { - Preconditions.checkNotNull(files, "Files to rename cannot be null."); - Preconditions.checkNotNull(toReplace, "String to be replaced cannot be null"); - Preconditions.checkNotNull(replacement, "Replacement string cannot be null"); - List paths = new LinkedList<>(); - for (File file : files) { - String fileName = file.getName(); - Path result = renameFile(file, fileName.replace(toReplace, replacement), precondition); - paths.add(result); - } - return paths; - } - - /** - * - * @param files - * The files to be copied. - * @param destination - * The destination directory. - * @return The list of paths to the the copied files. - * @throws IOException - * @throws IllegalArgumentDestination - * If destination is not a directory. - */ - public List moveFiles(final Collection files, final File destination) throws IOException { - if (files == null || destination == null) { - throw new NullPointerException("files and destination cannot be null."); - } - if (!destination.isDirectory()) { - throw new IllegalArgumentException("Destination must be a directory."); - } - List paths = new LinkedList<>(); - for (File file : files) { - Path p = destination.toPath().resolve(file.getName()); - Path result = Files.move(file.toPath(), p, StandardCopyOption.REPLACE_EXISTING); - paths.add(result); - } - return paths; - } - - public List copyFiles(final Collection fileNames, final NameToPath converter, final File destination, - HasPrerequisite precondition) throws IOException { - if (fileNames == null || destination == null) { - throw new NullPointerException("files and destination cannot be null."); - } - if (!destination.isDirectory()) { - throw new IllegalArgumentException("Destination must be a directory."); - } - List paths = new LinkedList<>(); - for (String file : fileNames) { - paths.add(_copyFile(destination, precondition, converter.resolve(file).toFile())); - } - return paths; - } - - /** - * - * @param files - * @param destination - * @param precondition - * @return - * @throws IOException - */ - public List copyFiles(final Collection files, final File destination, - HasPrerequisite precondition) throws IOException { - Preconditions.checkArgument(files != null && destination != null, "files and destination cannot be null."); - Preconditions.checkArgument(destination.isDirectory(), - "Destination " + destination.getName() + " is not a directory."); - if (precondition == null) { - precondition = new HasPrerequisite.EmptyCondition<>(); - } - return _copyFiles(files, destination, precondition); - } - - private List _copyFiles(final Collection files, final File destination, - HasPrerequisite precondition) throws IOException { - List paths = new LinkedList<>(); - for (File file : files) { - Path result = _copyFile(destination, precondition, file); - if (result != null) - paths.add(result); - } - return paths; - } - - private Path _copyFile(final File destination, HasPrerequisite precondition, File file) throws IOException { - if (precondition.isMet(file)) { - Path p = destination.toPath().resolve(file.getName()); - return Files.copy(file.toPath(), p, StandardCopyOption.REPLACE_EXISTING); - } - return null; - } - - /** - * - * @param sourceDir - * @param destination - * @return - * @throws IOException - */ - public Path copyDirectory(File sourceDir, File destination) throws IOException { - return copyDirectory(sourceDir.toPath(), destination.toPath()); - } - - /** - * - * @param source - * @param destination - * @return - * @throws IOException - */ - public Path copyDirectory(Path source, Path destination) throws IOException { - if (!Files.exists(source)) { - throw new IOException("Cannot copy directory tree from source: " + source.toString() - + ". Source directory does not exist."); - } - if (destination.startsWith(source)) { - throw new IllegalArgumentException("Cannot copy directory structure into subdirectory of itself."); - } - if (!Files.exists(destination)) { - Files.createDirectories(destination); - } - CopyDirVisitor visitor = new CopyDirVisitor(source, destination); - return Files.walkFileTree(source, visitor); - } - - /** - * - * @param file - * @param mimeType - * @return - */ - public boolean isFileType(final File file, final String extension) { - return file.getName().endsWith(extension); - } - - /** - * - * @param root - * @throws IOException - */ - public void emptyDir(final File root) throws IOException { - emptyDir(root, false); - } - - public void emptyDir(final Path root) throws IOException { - emptyDir(root, false); - } - - /** - * - * @param root - * @param deleteRoot - * @throws IOException - */ - public void emptyDir(final File root, boolean deleteRoot) throws IOException { - emptyDir(root.toPath(), deleteRoot); - } - - public void emptyDir(final Path root, boolean deleteRoot) throws IOException { - DeleteDirVisitor visitor = new DeleteDirVisitor(root, deleteRoot); - Files.walkFileTree(root, visitor); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/LibResourceToPath.java b/src/main/java/com/gtnexus/appxpress/commons/file/LibResourceToPath.java deleted file mode 100644 index 9287c04..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/file/LibResourceToPath.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.gtnexus.appxpress.commons.file; - -import java.nio.file.Path; - -public class LibResourceToPath implements NameToPath { - - private final Path libPath; - - public LibResourceToPath(Path libPath) { - this.libPath = libPath; - } - - @Override - public Path resolve(String name) { - return libPath.resolve(name); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/commons/file/NameToPath.java b/src/main/java/com/gtnexus/appxpress/commons/file/NameToPath.java deleted file mode 100644 index ed6de98..0000000 --- a/src/main/java/com/gtnexus/appxpress/commons/file/NameToPath.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.gtnexus.appxpress.commons.file; - -import java.nio.file.Path; - -public interface NameToPath { - - public Path resolve(String name); - -} diff --git a/src/main/java/com/gtnexus/appxpress/context/AppXpressContext.java b/src/main/java/com/gtnexus/appxpress/context/AppXpressContext.java deleted file mode 100644 index da34a76..0000000 --- a/src/main/java/com/gtnexus/appxpress/context/AppXpressContext.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.gtnexus.appxpress.context; - -import static com.gtnexus.appxpress.AppXpressConstants.LIB; - -import java.io.File; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.Options; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.DirectoryHelper; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.properties.PropertiesPersister; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; - -/** - * @author jdonovan - * - * @param - */ -public class AppXpressContext - implements SimpleShutdown, PMMCommandInfo, TempResourceHolder { - - private final PMMCommandInfo app; - private final DirectoryHelper dHelper; - private final Options options; - private final Map optMap; - private final PMProperties properties; - private final SimpleShutdown shutdown; - private final List delOnExit; - private boolean terminatedRegulary; - - public AppXpressContext(PMMCommandInfo app, SimpleShutdown shutdown, DirectoryHelper dHelper, Options options, - PMProperties properties, Map optMap) { - this.app = app; - this.shutdown = shutdown; - this.dHelper = dHelper; - this.optMap = optMap; - this.properties = properties; - this.options = options; - this.delOnExit = new LinkedList<>(); - this.terminatedRegulary = true; - } - - public PMMCommandInfo getApplicationInfo() { - return app; - } - - public Map getOptMap() { - return optMap; - } - - public Path getLibPath() { - String ld = properties.getProperty(BuilderOption.LOCAL_DIR); - Path localDir = Paths.get(ld); - return localDir.getParent().resolve(LIB); - } - - public PMProperties getPMProperties() throws AppXpressException { - return dHelper.getPmProperties(); - } - - public String getProperty(CLICommandOption option) { - return properties.getProperty(option.getLongName()); - } - - public void displayHelpAndExit() { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp(app.getName(), app.getHelpHeader(), options, app.getHelpFooter()); - shutdown(); - } - - public String getHelpHeader() { - return app.getHelpHeader(); - } - - public String getHelpFooter() { - return app.getHelpHeader(); - } - - @Override - public void shutdown() { - shutdown.shutdown(); - } - - @Override - public void shutdown(String message) { - shutdown.shutdown(message); - } - - @Override - public String getName() { - return app.getName(); - } - - @Override - public Class getContextType() { - return app.getContextType(); - } - - public void deleteOnExit(File f) { - delOnExit.add(f); - } - - public List getFilesToDeleteOnExit() { - return delOnExit; - } - - public boolean propertiesWereChanged() { - return properties.haveChanged(); - } - - public void presentSaveOption() throws AppXpressException { - PropertiesPersister sister = new PropertiesPersister(properties); - sister.presentSaveOption(); - } - - public boolean isTerminatedRegulary() { - return terminatedRegulary; - } - - public void setTerminatedRegulary(boolean terminatedRegulary) { - this.terminatedRegulary = terminatedRegulary; - } - - @Override - public Set getOptions() { - return null; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/context/ContextBasedCleanUp.java b/src/main/java/com/gtnexus/appxpress/context/ContextBasedCleanUp.java deleted file mode 100644 index 2fd3f41..0000000 --- a/src/main/java/com/gtnexus/appxpress/context/ContextBasedCleanUp.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.gtnexus.appxpress.context; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.file.FileCleanup; -import com.gtnexus.appxpress.exception.AppXpressException; - -/** - * Used {@link FileCleanup} to delete all temporary files marked for deletion by - * a {@link TempResourceHolder} - * - * @author jdonovan - * @param - * - */ -public class ContextBasedCleanUp implements Runnable { - - private final AppXpressContext ctx; - private final FileCleanup cleanup; - - public ContextBasedCleanUp(AppXpressContext context) { - this.ctx = context; - this.cleanup = new FileCleanup(); - } - - @Override - public void run() { - checkToSave(); - cleanup.cleanup(ctx.getFilesToDeleteOnExit()); - } - - public void checkToSave() { - if (ctx.isTerminatedRegulary() && ctx.propertiesWereChanged()) { - try { - ctx.presentSaveOption(); - } catch (AppXpressException e) { - System.out.println("Could not save properties file. Continuing with cleanup."); - } - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/context/ContextFactory.java b/src/main/java/com/gtnexus/appxpress/context/ContextFactory.java deleted file mode 100644 index 6bd0e48..0000000 --- a/src/main/java/com/gtnexus/appxpress/context/ContextFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.gtnexus.appxpress.context; - -import java.util.Map; -import java.util.Set; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.CLIOptsAndPropConsolidator; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.CLIOptionInterpreter; -import com.gtnexus.appxpress.cli.option.CLIOptionParser; -import com.gtnexus.appxpress.cli.option.ParsedOptions; -import com.gtnexus.appxpress.commons.DirectoryHelper; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdownImpl; -import com.gtnexus.appxpress.exception.AppXpressException; - -public class ContextFactory { - - private final AppXpressDirResolver resolver; - private final InterpreterFactory interpreterFac; - - public ContextFactory() { - this.resolver = new AppXpressDirResolver(); - this.interpreterFac = new InterpreterFactory(resolver); - } - - public AppXpressContext createContext(PMMCommandInfo app, String[] args) - throws AppXpressException { - DirectoryHelper dHelper = new DirectoryHelper(); - dHelper.ensureAppXpress(); - PMProperties pmProperties = dHelper.getPmProperties(); - Set options = app.getOptions(); - CLIOptionParser parser = CLIOptionParser.createParser(options, args); - ParsedOptions parsedOptions = parser.parse(); - SimpleShutdown shutdown = new SimpleShutdownImpl(); - CLIOptionInterpreter interpreter = interpreterFac.createInterpreter(app, shutdown, parsedOptions, - pmProperties); - Map interpretedOptions = interpreter.interpret(); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(interpretedOptions, - parsedOptions.getCliOptionSet(), pmProperties); - Map optMap = consolidator.consolidate(); - return new AppXpressContext<>(app, shutdown, dHelper, parser.getOptions(), pmProperties, optMap); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/context/InterpreterFactory.java b/src/main/java/com/gtnexus/appxpress/context/InterpreterFactory.java deleted file mode 100644 index 0e4bf94..0000000 --- a/src/main/java/com/gtnexus/appxpress/context/InterpreterFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.gtnexus.appxpress.context; - -import java.io.File; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.FileSelector; -import com.gtnexus.appxpress.cli.Select; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.CLIOptionInterpreter; -import com.gtnexus.appxpress.cli.option.ParsedOptions; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOptionInterpreter; -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; -import com.gtnexus.appxpress.pmdocgen.cli.DocumentGeneratorOptionInterpreter; -import com.gtnexus.appxpress.pmdocgen.cli.option.DocumentGeneratorOptions; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOptionInterpreter; - -/** - * - * @author jdonovan - * - */ -public class InterpreterFactory { - - private final AppXpressDirResolver resolver; - - public InterpreterFactory(AppXpressDirResolver resolver) { - this.resolver = resolver; - } - - /** - * - * @param contextType - * @param optionss - * @throws IllegalArgumentException - * if contextType is not supported. - * @return - * @throws PMBuilderException - */ - @SuppressWarnings("unchecked") - public CLIOptionInterpreter createInterpreter(PMMCommandInfo app, - SimpleShutdown shutdown, ParsedOptions options, PMProperties properties) throws PMBuilderException { - Class contextType = app.getContextType(); - Select selector = new FileSelector(System.in, System.out); - if (contextType.equals(BuilderOption.class)) { - // TODO: we need to remove the unchecked conversion - return (CLIOptionInterpreter) new BuilderOptionInterpreter(app, shutdown, - (ParsedOptions) options, properties, selector, resolver); - } else if (contextType.equals(ExtractorOption.class)) { - // TODO: we need to remove the unchecked conversion - return (CLIOptionInterpreter) new ExtractorOptionInterpreter(app, shutdown, - (ParsedOptions) options, properties, selector, resolver); - } else if (contextType.equals(DocumentGeneratorOptions.class)) { - return (CLIOptionInterpreter) new DocumentGeneratorOptionInterpreter(app, shutdown, - (ParsedOptions) options, properties, selector, resolver); - } - throw new IllegalArgumentException("Unsupported context type."); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/context/TempResourceHolder.java b/src/main/java/com/gtnexus/appxpress/context/TempResourceHolder.java deleted file mode 100644 index 6a5a95f..0000000 --- a/src/main/java/com/gtnexus/appxpress/context/TempResourceHolder.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.gtnexus.appxpress.context; - -import java.io.File; -import java.util.List; - -/** - * Holds references to temp files that should be deleted by a shutdown hook or - * some other means. - * - * @author jdonovan - * - */ -public interface TempResourceHolder { - - public void deleteOnExit(File f); - - public List getFilesToDeleteOnExit(); - -} diff --git a/src/main/java/com/gtnexus/appxpress/platform/module/ModulePointer.java b/src/main/java/com/gtnexus/appxpress/platform/module/ModulePointer.java deleted file mode 100644 index 127106d..0000000 --- a/src/main/java/com/gtnexus/appxpress/platform/module/ModulePointer.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gtnexus.appxpress.platform.module; - -import java.io.File; -import java.util.Map; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmdocgen.PlatformModuleDocumentGenerator; - -public class ModulePointer { - - private final File localDir; - private final File targetModule; - - public static ModulePointer make(Map optMap) throws AppXpressException { - File localDir = new File(optMap.get(PlatformModuleDocumentGenerator.localDirOpt)); - File target = localDir.toPath().resolve(optMap.get(PlatformModuleDocumentGenerator.customerOpt)) - .resolve(optMap.get(PlatformModuleDocumentGenerator.moduleOpt)).toFile(); - if (!localDir.exists()) { - throw new RuntimeException("Fatal error. LocalDir should be set prior to execution."); - } - if (!target.exists()) { - throw new AppXpressException("PMM was unable to locate the module (" + target.toString() + ")." - + " Are you sure this is the correct customer and module name?"); - } - - return new ModulePointer(localDir, target); - } - - public ModulePointer(File localDir, File targetModule) { - super(); - this.localDir = localDir; - this.targetModule = targetModule; - } - - public File getLocalDir() { - return localDir; - } - - public File getTargetModule() { - return targetModule; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/BuildCommand.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/BuildCommand.java deleted file mode 100644 index 9d5e381..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/BuildCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder; - -import com.google.common.base.Preconditions; -import com.gtnexus.appxpress.commons.command.Command; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextFactory; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; - -public class BuildCommand implements Command { - - private String[] args; - private ContextFactory contextFactory; - - public BuildCommand(String... args) { - Preconditions.checkNotNull(args); - this.args = args; - this.contextFactory = new ContextFactory(); - } - - @Override - public void execute() throws AppXpressException { - PlatformModuleBuilder pmb = new PlatformModuleBuilder(); - AppXpressContext context; - try { - context = contextFactory.createContext(pmb, args); - pmb.build(context); - } catch (AppXpressException e) { - throw new AppXpressException("build has failed.", e); - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/ModifyXMLDOM.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/ModifyXMLDOM.java deleted file mode 100644 index aa2b0f6..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/ModifyXMLDOM.java +++ /dev/null @@ -1,214 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.JS_EXTENSION; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTING_FEATURE; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; - -import java.io.File; -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * Modifies an xml file to include a specific tag, that being scriptingFeature - * - * @author Andrew Reynolds - * @Author john donovan - * @version 1.0 - * @date 8-27-2014 GT Nexus - */ -@Deprecated -public class ModifyXMLDOM { - - private static final String XML_DESIGN_TAG = "CustomObjectDesignV110"; - private static final String TEXT_JS = "text/javascript"; - private static final String APPLICATION_ZIP = "application/zip"; - private static final String FILENAME = "fileName"; - private static final String FIELD_MASKING_ENABLED = "fieldMaskingEnabled"; - private static final String MIME_TYPE = "mimeType"; - private static final String DESCRIPTION = "description"; - private static final String GENERIC_FILE_JS = "generic.js"; - private static final String GENERIC_FILE_ZIP = "generic.zip"; - - /** - * @param path - * path of xml file - * @param co - * custom object name - * @param isJS - * true if scriptingFeature should indicate a js file false if - * scriptingFeature should indicate a zip file - */ - public static void modify(String path, String co, boolean isJS) { - File xmlFile = new File(path); - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder; - try { - dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(xmlFile); - doc.getDocumentElement().normalize(); - if (hasScriptingTag(doc)) { - if (isJS) { - updateTagJs(doc, co); - } else { - updateTagZip(doc, co); - } - } else { - addScriptingTag(doc, co, isJS); - } - // write the updated document to file or console - doc.getDocumentElement().normalize(); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - Transformer transformer = transformerFactory.newTransformer(); - DOMSource source = new DOMSource(doc); - StreamResult result = new StreamResult(new File(path)); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(source, result); - System.out.println("XML file updated successfully"); - } catch (SAXException | ParserConfigurationException | IOException | TransformerException e1) { - System.err.println("Cannot find file - > " + xmlFile); - } - } - - /** - * Checks the xml DOM to see if the scriptingFeature tag is included in the tree - * - * @param doc - * XML document object to search through - */ - private static boolean hasScriptingTag(Document doc) { - NodeList scriptingFeature = doc.getElementsByTagName(SCRIPTING_FEATURE); - if (scriptingFeature.getLength() == 0) { - return false; - } else { - return true; - } - } - - /** - * Updates the scriptingFeature tag to indicate presence of 1 custom object JS - * file - * - * @param doc - * XML document object - * @param co - * Custom object name - */ - private static void updateTagJs(Document doc, String co) { - NodeList scriptingTag = doc.getElementsByTagName(SCRIPTING_FEATURE); - Element elm = (Element) scriptingTag.item(0); - Node name = elm.getElementsByTagName(MIME_TYPE).item(0).getFirstChild(); - name.setNodeValue(TEXT_JS); - String jsName = SCRIPT_DESIGN + $ + co + JS_EXTENSION; - name = elm.getElementsByTagName(FILENAME).item(0).getFirstChild(); - name.setNodeValue(jsName); - } - - /** - * Updates the scriptingFeature tag to indicate presence of more than one custom - * object JS files - therefore the files must be zipped up in order to properly - * import - * - * @param doc - * XML document object - * @param co - * Name of custom object - */ - private static void updateTagZip(Document doc, String co) { - NodeList scriptingTag = doc.getElementsByTagName(SCRIPTING_FEATURE); - Element elm = (Element) scriptingTag.item(0); - Node name = elm.getElementsByTagName(MIME_TYPE).item(0).getFirstChild(); - name.setNodeValue(APPLICATION_ZIP); - String zipName = SCRIPT_DESIGN + $ + co + ZIP_EXTENSION; - name = elm.getElementsByTagName(FILENAME).item(0).getFirstChild(); - name.setNodeValue(zipName); - } - - /** - * Adds scriptingTag to DOM of xml script design. Adds the tag as a jsFile if - * jsFile is true or a zip file is jsFile is false - * - * @param doc - * XML document object - * @param isJsFile - * true if indicating a js file false if indicating a zip file - * @param customObjectName - * Name of custom object - */ - private static void addScriptingTag(Document doc, String customObjectName, boolean isJsFile) { - NodeList dom = doc.getElementsByTagName(XML_DESIGN_TAG); - Node xmlDesignTag = null; - if (dom != null && (xmlDesignTag = dom.item(0)) != null) { - xmlDesignTag.appendChild(generateScriptingTag(doc, customObjectName, isJsFile)); - } - } - - /** - * @param doc - * @param customObjectName - * @param isJsFile - */ - private static Node generateScriptingTag(Document doc, String customObjectName, boolean isJsFile) { - final String _true = "true"; - final String _enabled = "enabled"; - Element scripting = doc.createElement(SCRIPTING_FEATURE); - Element enabled = doc.createElement(_enabled); - enabled.appendChild(doc.createTextNode(_true)); - scripting.appendChild(enabled); - Element mime = doc.createElement(MIME_TYPE); - mime.appendChild(doc.createTextNode(getMimeType(isJsFile))); - scripting.appendChild(mime); - Element description = doc.createElement(DESCRIPTION); - description.appendChild(doc.createTextNode(getDescriptionType(isJsFile))); - scripting.appendChild(description); - Element filename = doc.createElement(FILENAME); - filename.appendChild(doc.createTextNode(getFileType(isJsFile, customObjectName))); - scripting.appendChild(filename); - Element fieldMaskingEnabled = doc.createElement(FIELD_MASKING_ENABLED); - fieldMaskingEnabled.appendChild(doc.createTextNode("true")); - scripting.appendChild(fieldMaskingEnabled); - return scripting; - } - - private static String getMimeType(boolean isJsFile) { - if (isJsFile) { - return TEXT_JS; - } else { - return APPLICATION_ZIP; - } - } - - private static String getDescriptionType(boolean isJsFile) { - if (isJsFile) { - return GENERIC_FILE_JS; - } else { - return GENERIC_FILE_ZIP; - } - } - - private static String getFileType(boolean isJsFile, String customObjectName) { - final String fileTypeTemplate = SCRIPT_DESIGN + $ + customObjectName + "%s"; - if (isJsFile) { - return String.format(fileTypeTemplate, JS_EXTENSION); - } else { - return String.format(fileTypeTemplate, ZIP_EXTENSION); - } - } - -} \ No newline at end of file diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilder.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilder.java deleted file mode 100644 index b5add4c..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilder.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder; - -import java.util.Set; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextBasedCleanUp; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.bundle.platform.BuildPrep; -import com.gtnexus.appxpress.pmbuilder.bundle.platform.PlatformModuleBundler; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; -import com.gtnexus.appxpress.pmbuilder.cli.PMBuilderVO; - -/** - * This executable does the following things in order with the end goal to - * create an importable .zip file. - * - *

    - *
  1. 1) Scans the javascripts in the platform module for the !import - * symbol. If found, automatically imports indicated scripts from lib/ into - * correct folder.
  2. - *
  3. 2) Makes sure each of the custom object design xml's contain the correct - * scriptingFeature tag, therefore ensuring that the platform module's scripts - * will import correctly.
  4. - *
  5. 3) Maps the local git structure to the folder structure required to - * become importable by GTNexus platform. This requires correct folder names and - * bundling javascript file into zip files when necessary.
  6. - *
  7. 4) Zips up correctly mapped file structure into a zip file, ready to - * import into GTNexus system
  8. - *
- * - * @author Andrew Reynolds - * @author john donovan - * @version 1.0 - * @date 8-27-2014 GT Nexus - */ -public class PlatformModuleBuilder implements PMMCommandInfo { - - private static final String NAME = "pmbuilder"; - - public PlatformModuleBuilder() { - } - - public void build(AppXpressContext context) throws AppXpressException { - attachCleanUpHook(context); - PMBuilderVO vo = new PMBuilderVO(context.getOptMap()); - BuildPrep prep = new BuildPrep(context, context.getLibPath()); - PlatformModuleBundler bundler = new PlatformModuleBundler(vo.getRootFile()); - try { - prep.prepare(vo); - bundler.bundle(vo.getWorkingDir()); - } catch (AppXpressException e) { - context.setTerminatedRegulary(false); - throw new AppXpressException("Failed to build module.", e); - } - } - - private void attachCleanUpHook(AppXpressContext ctx) { - Runtime.getRuntime().addShutdownHook(new Thread(new ContextBasedCleanUp<>(ctx))); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public Class getContextType() { - return BuilderOption.class; - } - - @Override - public String getHelpHeader() { - return ""; - } - - @Override - public String getHelpFooter() { - return ""; - } - - @Override - public Set getOptions() { - return BuilderOption.getAllOptions(); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/Bundler.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/Bundler.java deleted file mode 100644 index 18243ef..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/Bundler.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle; - -import java.io.File; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public interface Bundler { - - public void bundle(File directory) throws AppXpressException; - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/AppXpressMapper.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/AppXpressMapper.java deleted file mode 100644 index ceb1c48..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/AppXpressMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle.platform; - -import java.io.File; - -import com.gtnexus.appxpress.commons.Mapper; -import com.gtnexus.appxpress.commons.Preparation; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.bundle.Bundler; -import com.gtnexus.appxpress.pmbuilder.bundle.scripts.FolderPrep; -import com.gtnexus.appxpress.pmbuilder.bundle.scripts.ScriptBundler; - -/** - * Replacement for PlatfromMapUtil. - * - * Takes a git repository and maps to a file structure that can be imported onto - * the platform. - * - * @author jdonovan - * - */ -public class AppXpressMapper implements Mapper { - - private final File root; - private final Bundler bundler; - private final Preparation prep; - - public AppXpressMapper(File root) { - this.root = root; - this.bundler = new ScriptBundler(); - this.prep = new FolderPrep(); - } - - /** - * Performs the directory mappings (renaming, moving, etc.) - */ - @Override - public void doMapping() throws AppXpressException { - if (root == null || !root.isDirectory()) { - System.err.println("Module root cannot be found, or is empty. " + "No mapping can be performed."); - return; - } - prep.prepare(root); - bundler.bundle(root); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/BuildPrep.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/BuildPrep.java deleted file mode 100644 index ec8a352..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/BuildPrep.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle.platform; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.commons.Mapper; -import com.gtnexus.appxpress.commons.Preparation; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.context.TempResourceHolder; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.cli.PMBuilderVO; -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; -import com.gtnexus.appxpress.pmbuilder.scriptimport.ImportService; - -/** - * - * @author jdonovan - * - */ -public class BuildPrep implements Preparation { - - private final FileService fs; - private final AppXpressDirResolver resolver; - private final TempResourceHolder tmpHolder; - private final Path libPath; - - public BuildPrep(TempResourceHolder tmp, Path libPath) { - this.fs = new FileService(); - this.resolver = new AppXpressDirResolver(); - this.tmpHolder = tmp; - this.libPath = libPath; - } - - @Override - public void prepare(final PMBuilderVO vo) throws PMBuilderException { - try { - File tmp = createTemp(vo); - vo.setWorkingDir(tmp); - runImportFind(tmp, libPath); - map(tmp); - } catch (AppXpressException | IOException e) { - throw new PMBuilderException("Exception when mapping file structure.", e); - } - } - - private File createTemp(final PMBuilderVO vo) throws IOException { - Path source = vo.getRootFile().toPath(); - Path tmpPath = resolver.resolveAppXpressDir().toAbsolutePath(); - String tmpPrefix = String.valueOf(System.currentTimeMillis()); - Path destination = Files.createTempDirectory(tmpPath, tmpPrefix); - File dest = destination.toFile(); - tmpHolder.deleteOnExit(dest); - fs.copyDirectory(source, destination); - return dest; - } - - /** - * Iterates through folder customer/customer/folder - * - * @param customer - * Name of customer folder - * @param folder - * Name of platform module folder - * @throws AppXpressException - */ - private void runImportFind(final File rootFile, final Path lib) throws AppXpressException { - System.out.println("Gathering imports..."); - ImportService iScanner = new ImportService(rootFile, lib); - iScanner.scanAndImport(); - } - - /** - * Maps pulled platform module to a file structure that can be imported onto - * GTNexus system - * - * @param root - * File path of platform module - */ - private void map(File rootFile) throws AppXpressException { - Mapper mapper = new AppXpressMapper(rootFile); - mapper.doMapping(); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/PlatformModuleBundler.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/PlatformModuleBundler.java deleted file mode 100644 index b060154..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/platform/PlatformModuleBundler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle.platform; - -import java.io.File; - -import com.gtnexus.appxpress.AppXpressConstants; -import com.gtnexus.appxpress.commons.ZipService; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.bundle.Bundler; - -public class PlatformModuleBundler implements Bundler { - - private final ZipService zs; - private final File root; - - public PlatformModuleBundler(File root) { - this.zs = new ZipService(AppXpressConstants.IGNORE_SET); - this.root = root; - } - - @Override - public void bundle(File dir) throws AppXpressException { - zs.zipDirectory(dir, root); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/FolderPrep.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/FolderPrep.java deleted file mode 100644 index 2d25f02..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/FolderPrep.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle.scripts; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_ACTION_D1; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_LINK_D1; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_OBJECT_MODULE; -import static com.gtnexus.appxpress.AppXpressConstants.DESIGN_; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTS; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; -import static com.gtnexus.appxpress.AppXpressConstants.TYPE_EXTENSION_D1; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; - -import com.gtnexus.appxpress.commons.HasPrerequisite; -import com.gtnexus.appxpress.commons.Preparation; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.commons.file.filter.ChainedAnd; -import com.gtnexus.appxpress.commons.file.filter.FileFilterChain; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.exception.AppXpressException; - -public class FolderPrep implements Preparation { - - private final FileService fs; - - public FolderPrep() { - fs = new FileService(); - } - - /** - * Renames directories, and handle's special cases for specific directories. - */ - @Override - public void prepare(File root) throws AppXpressException { - for (File dir : root.listFiles(FileFilterFactory.directoriesOnly())) { - try { - route(dir); - } catch (IOException e) { - throw new AppXpressException("Exception when preparing " + dir.toString() + ".", e); - } - } - } - - private void route(File dir) throws IOException { - String directoryName = dir.getName(); - if (needsRenaming(dir)) { - fs.prependToName(dir, $); - } else if (directoryName.endsWith(CUSTOM_OBJECT_MODULE)) { - fixCustomObjectModule(dir); - } - } - - private boolean needsRenaming(File dir) { - String directoryName = dir.getName(); - return directoryName.equals(CUSTOM_LINK_D1) || directoryName.equals(TYPE_EXTENSION_D1) - || directoryName.equals(CUSTOM_ACTION_D1); - } - - /** - * - * @param directory - */ - private void fixCustomObjectModule(File directory) throws IOException { - File designFolder = directory.toPath().resolve("designs").toFile(); - if (designFolder.exists()) { - renameWhenNecessary(designFolder.listFiles(), DESIGN_, DESIGN_ + $); - } - File scriptFolder = directory.toPath().resolve(SCRIPTS).toFile(); - if (scriptFolder.exists()) { - FileFilterChain directoriesWithoutSigil = new ChainedAnd().and(FileFilterFactory.directoriesOnly()) - .and(FileFilterFactory.fileNameDoesNotContain("_$")); - File[] files = scriptFolder.listFiles(directoriesWithoutSigil); - fs.renameFile(Arrays.asList(files), SCRIPT_DESIGN, SCRIPT_DESIGN + $); - } - File xsdFolder = directory.toPath().resolve("xsd").toFile(); - if (xsdFolder.exists()) { - prependWhenNecessary(xsdFolder.listFiles(), $); - } - } - - private void renameWhenNecessary(final File[] files, final String toReplace, final String replacement) - throws IOException { - HasPrerequisite precondition = doesNotStartWith(replacement); - fs.renameFile(Arrays.asList(files), toReplace, replacement, precondition); - } - - private void prependWhenNecessary(final File[] files, final String prepend) throws IOException { - fs.prependToName(Arrays.asList(files), prepend, doesNotStartWith(prepend)); - } - - private HasPrerequisite doesNotStartWith(final String string) { - return new HasPrerequisite() { - @Override - public boolean isMet(File f) { - return !f.getName().startsWith(string); - } - }; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/ScriptBundler.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/ScriptBundler.java deleted file mode 100644 index 9ed3774..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/bundle/scripts/ScriptBundler.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.bundle.scripts; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.BUNDLE; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_UI; -import static com.gtnexus.appxpress.AppXpressConstants.DESIGNS; -import static com.gtnexus.appxpress.AppXpressConstants.JS_EXTENSION; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTS; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import com.gtnexus.appxpress.commons.ZipService; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.commons.file.filter.ChainedAnd; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.bundle.Bundler; -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; -import com.gtnexus.appxpress.pmextractor.exception.PMExtractorException; - -/** - * - * @author jdonovan - * - */ -public class ScriptBundler implements Bundler { - - private final ZipService zs; - private final FileService fs; - - public ScriptBundler() { - this.zs = new ZipService(); - this.fs = new FileService(); - } - - @Override - public void bundle(final File directory) throws AppXpressException { - for (File f : directory.listFiles(FileFilterFactory.directoriesOnly())) { - searchForPotentialBundles(f); - } - } - - private void searchForPotentialBundles(final File dir) throws PMBuilderException { - if (wasSpecialCase(dir)) { - return; - } - bundleGenerically(dir); - } - - private boolean wasSpecialCase(final File dir) { - final String platformIndependent = DESIGNS + File.separator + SCRIPTS; - boolean isSpecial = false; - try { - if (dir.getAbsolutePath().toLowerCase().contains(platformIndependent.toLowerCase())) { - handleCustomObjectDesignScripts(dir); - isSpecial = true; - } else if (dir.getName().endsWith(CUSTOM_UI)) { - handleFef(dir); - isSpecial = true; - } - } catch (PMExtractorException e) { - System.err.println("Unable to handle special case. Caused by: "); - System.err.println(e.getMessage()); - System.out.println("Defaulting to standard bundling."); - isSpecial = false; - } - return isSpecial; - } - - private void bundleGenerically(final File dir) throws PMBuilderException { - final List jsFiles = new LinkedList<>(); - for (File f : dir.listFiles()) { - if (fs.isFileType(f, JS_EXTENSION)) { - jsFiles.add(f); - } else if (f.isDirectory()) { - searchForPotentialBundles(f); - } - } - if (jsFiles.size() > 1) { - try { - zs.zipFiles(jsFiles, dir.getAbsolutePath() + BUNDLE + ZIP_EXTENSION); - fs.emptyDir(dir, true); - } catch (AppXpressException | IOException e) { - throw new PMBuilderException("Failed to bundle directory generically", e); - } - } - } - - /** - * Handle's special logic for handling the directory for the Front End Framework - * - * @param dir - * @throws PMExtractorException - */ - private void handleFef(final File dir) throws PMExtractorException { - final ChainedAnd filter = new ChainedAnd(FileFilterFactory.directoriesOnly(), - FileFilterFactory.doesNotEndWith(ZIP_EXTENSION)); - if (filter.hasResults(dir)) { - Path customUiBundle = dir.toPath().resolve("CustomUIBundle"); - try { - addPathsToUIBundle(filter.listPaths(dir), customUiBundle); - zs.zipDirectory(customUiBundle); - fs.emptyDir(customUiBundle, true); - } catch (AppXpressException | IOException e) { - throw new PMExtractorException("Could not handle FEF", e); - } - } - } - - private void addPathsToUIBundle(Collection paths, Path customUiBundle) throws IOException { - for (Path subdir : paths) { - fs.copyDirectory(subdir, customUiBundle.resolve(subdir.getFileName())); - } - } - - /** - * @param dir - * The CustomObject/designs/scripts directory. - * @throws PMExtractorException - */ - private void handleCustomObjectDesignScripts(final File dir) throws PMExtractorException { - for (File subDir : dir.listFiles(FileFilterFactory.directoriesOnly())) { - handleSingleCODScript(subDir); - } - } - - private void handleSingleCODScript(final File dir) throws PMExtractorException { - Path p = dir.toPath(); - try { - if (dir.list().length == 1) { - moveUpAndRename(dir); - } else if (dir.list().length > 1) { - p = bundleCODScript(dir); - zs.zipDirectory(p); - } - fs.emptyDir(p, true); - } catch (AppXpressException | IOException e) { - throw new PMExtractorException("Couldn't handle single custom object design script " + dir.toString(), e); - } - } - - private Path bundleCODScript(final File dir) throws IOException { - String rename = SCRIPT_DESIGN + $ + dir.getName(); - Path newPath = dir.toPath().resolveSibling(rename); - return Files.move(dir.toPath(), newPath); - } - - private Path moveUpAndRename(final File dir) throws IOException { - String newName = dir.getName(); - newName = scriptNameForDir(dir); - Path newPath = dir.toPath().resolveSibling(newName); - File loneFile = dir.listFiles()[0]; - return Files.move(loneFile.toPath(), newPath); - } - - private String scriptNameForDir(File dir) { - String name = dir.getName(); - if (name.startsWith(SCRIPT_DESIGN) && name.startsWith(SCRIPT_DESIGN + $)) { - return name + JS_EXTENSION; - } - if (name.startsWith(SCRIPT_DESIGN) && !name.startsWith(SCRIPT_DESIGN + $)) { - return name.replace(SCRIPT_DESIGN, SCRIPT_DESIGN + $) + JS_EXTENSION; - } else { - return SCRIPT_DESIGN + $ + name + JS_EXTENSION; - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOption.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOption.java deleted file mode 100644 index 4e6bf5c..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOption.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.cli; - -import java.util.EnumSet; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -public enum BuilderOption implements CLICommandOption { - HELP("h", "help", String.class, "Display usage for this tool", false, false, null), CUSTOMER("c", "customer", - String.class, "The customer who owns this module.", true, true, - null), MODULE("m", "module", String.class, "The name of the module.", true, true, null), LOCAL_DIR("ld", - "localDir", String.class, "Relative Path of git staging folder.", true, true, null), SELECT("s", - "select", Integer.class, "Select platform from the folders present in the cwd.", false, - false, null); - - private final String flag; - private final String name; - private final Class type; - private final boolean hasArg; - private final boolean isMandatory; - private final String defaultValue; - private final String description; - private static final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private static final ValidityProvider validityProvider = new ValidityProvider(); - - private final static Set allOptions = new ImmutableSet.Builder() - .addAll(EnumSet.allOf(BuilderOption.class)).build(); - - private BuilderOption(String flag, String name, Class type, String description, boolean hasArg, - boolean isMandatory, String defaulValue) { - this.flag = flag; - this.name = name; - this.type = type; - this.hasArg = hasArg; - this.description = description; - this.isMandatory = isMandatory; - this.defaultValue = defaulValue; - } - - @Override - public String getLongName() { - return name; - } - - @Override - public Class getType() { - return type; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public boolean hasArg() { - return hasArg; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(type, name); - } - - @Override - public boolean isAppXpressMandatory() { - return isMandatory; - } - - @Override - public boolean shouldBeOmitted() { - return !isMandatory && defaultValue == null; - } - - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, type); - } - - @Override - public String getDefaultValue() { - if (this.isMandatory) { - throw new UnsupportedOperationException(this.name + " is a mandatory field, and must come from " - + "user args or properties. There is no default value."); - } - return defaultValue; - } - - @Override - public String getFlag() { - return flag; - } - - @Override - public boolean isStoreableProperty() { - if (this == LOCAL_DIR) { - return true; - } - return false; - } - - @Override - public boolean isHelpFlag() { - return this.equals(HELP); - } - - public static Set getAllOptions() { - return allOptions; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOptionInterpreter.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOptionInterpreter.java deleted file mode 100644 index e069298..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/BuilderOptionInterpreter.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.cli; - -import java.io.File; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.Select; -import com.gtnexus.appxpress.cli.option.CLICommandOptionInterpreter; -import com.gtnexus.appxpress.cli.option.CLIOptionInterpreter; -import com.gtnexus.appxpress.cli.option.ParsedOptions; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; - -/** - * - * @author jdonovan - * - */ -public class BuilderOptionInterpreter extends CLICommandOptionInterpreter - implements CLIOptionInterpreter { - - private final Select selector; - private final AppXpressDirResolver resolver; - - public BuilderOptionInterpreter(PMMCommandInfo app, SimpleShutdown shutdown, - ParsedOptions parsedOptions, PMProperties properties, Select selector, - AppXpressDirResolver resolver) { - super(app, shutdown, parsedOptions, properties); - this.selector = selector; - this.resolver = resolver; - } - - @Override - public ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) - throws AppXpressException { - if (parsedOpts == null) { - throw new NullPointerException("parsedOpts cannot be null"); - } - Path cwd = resolver.resovleCurrentDirectory(); - if (parsedOpts.hasOption(BuilderOption.SELECT)) { - doSelect(parsedOpts, cwd); - } - if (isCandidateForArgInjection(parsedOpts, cwd)) { - parsedOpts.put(BuilderOption.CUSTOMER, cwd); - } - return parsedOpts; - } - - private void doSelect(ParsedOptions parsedOpts, Path cwd) - throws AppXpressException, PMBuilderException { - if (!isCustomerFolder(cwd, BuilderOption.LOCAL_DIR)) { - throw new PMBuilderException("The select option must be run from a customer folder."); - } - Collection choices = getCandidates(cwd); - if (choices.isEmpty()) { - throw new PMBuilderException("Nothing to select from!"); - } - File selection = selector.select(choices); - parsedOpts.put(BuilderOption.MODULE, selection); - parsedOpts.put(BuilderOption.CUSTOMER, cwd); - } - - private boolean isCandidateForArgInjection(ParsedOptions parsedOpts, Path cwd) - throws AppXpressException { - return !parsedOpts.hasOption(BuilderOption.CUSTOMER) && isCustomerFolder(cwd, BuilderOption.LOCAL_DIR); - } - - private Collection getCandidates(Path dir) { - File[] files = dir.toFile().listFiles(FileFilterFactory.directoriesOnly()); - return Arrays.asList(files); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/PMBuilderVO.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/PMBuilderVO.java deleted file mode 100644 index 3e9bba8..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/cli/PMBuilderVO.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.cli; - -import java.io.File; -import java.util.Map; - -public class PMBuilderVO { - - private final File localDir; - private final File rootFile; - private File workingDir; - - public PMBuilderVO(Map optionMap) { - this.localDir = new File(optionMap.get(BuilderOption.LOCAL_DIR)); - this.rootFile = localDir.toPath().resolve(optionMap.get(BuilderOption.CUSTOMER)) - .resolve(optionMap.get(BuilderOption.MODULE)).toFile(); - } - - public File getLocalDir() { - return localDir; - } - - public File getRootFile() { - return rootFile; - } - - public File getWorkingDir() { - return workingDir; - } - - public void setWorkingDir(File workingDir) { - this.workingDir = workingDir; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagAppender.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagAppender.java deleted file mode 100644 index f0bcbf4..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagAppender.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTING_FEATURE; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; - -import java.io.File; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class AppXpressScriptDesignTagAppender implements ScriptDesignTagModifier { - - private final Document xml; - private final File customObject; - private final String fileExtension; - private final String mimeTypeValue; - private final String genericFileName; - - AppXpressScriptDesignTagAppender(Document xml, File customObject, String fileExtension, String mimeTypeValue, - String genericFileName) { - this.xml = xml; - this.customObject = customObject; - this.fileExtension = fileExtension; - this.mimeTypeValue = mimeTypeValue; - this.genericFileName = genericFileName; - } - - @Override - public void modifyAsNeeded() { - addScriptingTag(xml, customObject.getName()); - } - - private void addScriptingTag(Document doc, String customObjectName) { - NodeList dom = doc.getElementsByTagName(XML_DESIGN_TAG); - Node xmlDesignTag = null; - if (dom != null && (xmlDesignTag = dom.item(0)) != null) { - xmlDesignTag.appendChild(generateScriptingTag(doc, customObjectName)); - } - } - - /** - * @param doc - * @param customObjectName - * @param isJsFile - */ - private Node generateScriptingTag(Document doc, String customObjectName) { - final String _true = "true"; - final String _enabled = "enabled"; - final Element scripting = doc.createElement(SCRIPTING_FEATURE); - final Element enabled = doc.createElement(_enabled); - enabled.appendChild(doc.createTextNode(_true)); - scripting.appendChild(enabled); - final Element mime = doc.createElement(MIME_TYPE); - mime.appendChild(doc.createTextNode(mimeTypeValue)); - scripting.appendChild(mime); - final Element description = doc.createElement(DESCRIPTION); - description.appendChild(doc.createTextNode(genericFileName)); - scripting.appendChild(description); - final Element filename = doc.createElement(FILENAME); - filename.appendChild(doc.createTextNode(buildFileName(customObjectName))); - scripting.appendChild(filename); - final Element fieldMaskingEnabled = doc.createElement(FIELD_MASKING_ENABLED); - fieldMaskingEnabled.appendChild(doc.createTextNode("true")); - scripting.appendChild(fieldMaskingEnabled); - return scripting; - } - - private String buildFileName(String customObjectName) { - final String fileTypeTemplate = SCRIPT_DESIGN + $ + customObjectName + "%s"; - return String.format(fileTypeTemplate, fileExtension); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagModifier.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagModifier.java deleted file mode 100644 index 9f42f4d..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/AppXpressScriptDesignTagModifier.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTING_FEATURE; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPT_DESIGN; - -import java.io.File; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class AppXpressScriptDesignTagModifier implements ScriptDesignTagModifier { - - private final Document xml; - private final File customObject; - private final String fileExtension; - private final String mimeTypeValue; - - AppXpressScriptDesignTagModifier(Document xml, File customObject, final String fileExtension, - final String mimeTypeValue) { - this.xml = xml; - this.customObject = customObject; - this.fileExtension = fileExtension; - this.mimeTypeValue = mimeTypeValue; - } - - @Override - public void modifyAsNeeded() { - updateTag(xml, customObject.getName()); - } - - public void updateTag(Document doc, String customObjectName) { - NodeList scriptingTag = doc.getElementsByTagName(SCRIPTING_FEATURE); - Element elm = (Element) scriptingTag.item(0); - Node name = elm.getElementsByTagName(MIME_TYPE).item(0).getFirstChild(); - name.setNodeValue(mimeTypeValue); - String fileName = SCRIPT_DESIGN + $ + customObjectName + fileExtension; - name = elm.getElementsByTagName(FILENAME).item(0).getFirstChild(); - name.setNodeValue(fileName); - } - -} \ No newline at end of file diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/CustomObjectDesignXML.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/CustomObjectDesignXML.java deleted file mode 100644 index c041b32..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/CustomObjectDesignXML.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -import static com.gtnexus.appxpress.AppXpressConstants.$; -import static com.gtnexus.appxpress.AppXpressConstants.CUSTOM_OBJECT_MODULE; -import static com.gtnexus.appxpress.AppXpressConstants.DESIGN_; -import static com.gtnexus.appxpress.AppXpressConstants.XML_EXTENSION; - -import java.io.File; - -import javax.xml.parsers.ParserConfigurationException; - -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; - -/** - * Ensures that custom object designs xml match up with their scripting - * - * @author Andrew Reynolds - * @author Eric Hu - * @author John Donovan - * @version 1.0 - * @date 8-27-2014 GT Nexus - */ -@Deprecated -public class CustomObjectDesignXML { - - private final String designPathTemplate = "%s" + File.separator + CUSTOM_OBJECT_MODULE + File.separator + "designs"; - private final String scriptPathTemplate = designPathTemplate + File.separator + "Scripts"; - private File moduleRoot; - private File designDirectory; - private File scriptDirectory; - - /** - * - * @param root - * - the root for this customer/module - */ - public CustomObjectDesignXML(File root) { - this.moduleRoot = root; - this.designDirectory = new File(String.format(designPathTemplate, root.getAbsolutePath())); - this.scriptDirectory = new File(String.format(scriptPathTemplate, root.getAbsolutePath())); - } - - /** - * - * @throws PMBuilderException - * If the module root does not exist, or there - * ParserConfigurationException. - */ - public void ensureSoundDesign() throws PMBuilderException { - if (!moduleRoot.exists()) { - throw new PMBuilderException("Cannot find path to customer: " + moduleRoot.getAbsolutePath()); - } - if (!preConditionsMet()) { - return; - } - ScriptingDesignEnsurer ensurer; - try { - ensurer = new ScriptingDesignEnsurer(); - } catch (ParserConfigurationException e) { - throw new PMBuilderException("Something went wrong. Could not ensure a sound design.", e); - } - checkEachScriptAndDesign(ensurer); - } - - /** - * Asserts that the necessary directories exist. In order for the scripts - * directory to exist the design directory must exist, so a single check is all - * that is necessary. - * - * @return - */ - private boolean preConditionsMet() { - if (!scriptDirectory.exists() || !scriptDirectory.isDirectory()) { - System.out.println("No scripts folder, must not be any CustomObject scripts"); - return false; - } - return true; - } - - /** - * - * @param ensurer - */ - private void checkEachScriptAndDesign(ScriptingDesignEnsurer ensurer) throws PMBuilderException { - final String correspondingXMLPathTemplate = designDirectory.getAbsolutePath() + File.separator + DESIGN_ + $ - + "%s" + XML_EXTENSION; - for (File script : scriptDirectory.listFiles()) { - File correspondingXML = formatPathTemplate(correspondingXMLPathTemplate, script.getName()); - boolean scriptingFeature = script.isDirectory() && script.list().length == 1; - ensurer.ensure(correspondingXML, script, scriptingFeature); - } - } - - private File formatPathTemplate(final String template, String scriptName) { - int last = scriptName.lastIndexOf($); - if (last != -1) { - scriptName = scriptName.substring(last + 1, scriptName.length()); - } - last = scriptName.lastIndexOf("."); - if (last != -1) { - scriptName = scriptName.substring(0, last); - } - String absolutePath = String.format(template, scriptName); - return new File(absolutePath); - } - -} \ No newline at end of file diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifier.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifier.java deleted file mode 100644 index 9dd726f..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifier.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -public interface ScriptDesignTagModifier { - - public static final String XML_DESIGN_TAG = "CustomObjectDesignV110"; - public static final String MIME_TYPE = "mimeType"; - public static final String FIELD_MASKING_ENABLED = "fieldMaskingEnabled"; - public static final String FILENAME = "fileName"; - public static final String DESCRIPTION = "description"; - - public void modifyAsNeeded(); - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifierFactory.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifierFactory.java deleted file mode 100644 index 8842395..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptDesignTagModifierFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -import static com.gtnexus.appxpress.AppXpressConstants.JS_EXTENSION; -import static com.gtnexus.appxpress.AppXpressConstants.SCRIPTING_FEATURE; -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; - -import java.io.File; - -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; - -public class ScriptDesignTagModifierFactory { - - private static final String TEXT_JS = "text/javascript"; - private static final String APPLICATION_ZIP = "application/zip"; - private static final String GENERIC_FILE_JS = "generic.js"; - private static final String GENERIC_FILE_ZIP = "generic.zip"; - - private static final FileDescriptorTriplet zipDescriptor = new FileDescriptorTriplet(ZIP_EXTENSION, APPLICATION_ZIP, - GENERIC_FILE_ZIP); - private static final FileDescriptorTriplet jsDescriptor = new FileDescriptorTriplet(JS_EXTENSION, TEXT_JS, - GENERIC_FILE_JS); - - public ScriptDesignTagModifierFactory() { - } - - public ScriptDesignTagModifier newTagModifierFor(final Document xml, final File customObject, final boolean isJS) { - if (isJS) { - return buildModifier(xml, customObject, jsDescriptor); - } else { - return buildModifier(xml, customObject, zipDescriptor); - } - } - - private ScriptDesignTagModifier buildModifier(final Document xml, final File customObject, - final FileDescriptorTriplet desc) { - if (hasScriptingTag(xml)) { - return new AppXpressScriptDesignTagModifier(xml, customObject, desc.fileExtension, desc.mimeType); - } else { - return new AppXpressScriptDesignTagAppender(xml, customObject, desc.fileExtension, desc.mimeType, - desc.genericFileName); - } - } - - /** - * Checks the xml DOM to see if the scriptingFeature tag is included in the tree - * - * @param doc - * XML document object to search through - */ - private boolean hasScriptingTag(final Document doc) { - final NodeList scriptingFeature = doc.getElementsByTagName(SCRIPTING_FEATURE); - if (scriptingFeature.getLength() == 0) { - return false; - } else { - return true; - } - } - - private static class FileDescriptorTriplet { - final String fileExtension, mimeType, genericFileName; - - FileDescriptorTriplet(final String fileExtension, final String mimeType, final String genericFileName) { - this.fileExtension = fileExtension; - this.mimeType = mimeType; - this.genericFileName = genericFileName; - } - - } -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptingDesignEnsurer.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptingDesignEnsurer.java deleted file mode 100644 index b36747c..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/design/ScriptingDesignEnsurer.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.design; - -import java.io.File; -import java.io.IOException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import com.gtnexus.appxpress.pmbuilder.exception.PMBuilderException; - -public class ScriptingDesignEnsurer { - - private final DocumentBuilder builder; - - public ScriptingDesignEnsurer() throws ParserConfigurationException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - builder = factory.newDocumentBuilder(); - } - - public void ensure(File xml, File customObject, boolean js) throws PMBuilderException { - if (xml == null || customObject == null) { - throw new NullPointerException("Cannot ensure design for null xml or null custom object"); - } - if (!xml.exists()) { - throw new PMBuilderException("Xml file " + xml.getAbsolutePath() - + " does not exist. Cannot ensure design for script " + customObject.getAbsolutePath() + " ."); - } - Document xmlDoc; - ScriptDesignTagModifierFactory factory = new ScriptDesignTagModifierFactory(); - try { - xmlDoc = builder.parse(xml); - factory.newTagModifierFor(xmlDoc, customObject, false).modifyAsNeeded(); - xmlDoc.getDocumentElement().normalize(); - TransformerFactory transformerFactory = TransformerFactory.newInstance(); - Transformer transformer = transformerFactory.newTransformer(); - DOMSource source = new DOMSource(xmlDoc); - StreamResult result = new StreamResult(xml); - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.transform(source, result); - } catch (SAXException | IOException | TransformerException e) { - throw new PMBuilderException("Exception when transforming xml!", e); - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/exception/PMBuilderException.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/exception/PMBuilderException.java deleted file mode 100644 index 25a8b8c..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/exception/PMBuilderException.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.exception; - -import com.gtnexus.appxpress.exception.AppXpressException; - -public class PMBuilderException extends AppXpressException { - - /** - * - */ - private static final long serialVersionUID = 5468857470158908903L; - - public PMBuilderException(String message) { - super(message); - } - - public PMBuilderException(Exception e) { - super(e); - } - - public PMBuilderException(String message, Exception e) { - super(message, e); - } -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFile.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFile.java deleted file mode 100644 index 83d8562..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFile.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.scriptimport; - -import java.io.File; -import java.net.URI; -import java.util.Arrays; -import java.util.List; - -/** - * Wrapper class to internalize some logic around what file's may contain import - * directives. - * - * @author jdonovan - * - */ -public class ImportFile extends File { - - private static final long serialVersionUID = -7530032818432622334L; - final List validExtensions = Arrays.asList("js"); - - public ImportFile(File parent, String child) { - super(parent, child); - } - - public ImportFile(String parent, String child) { - super(parent, child); - } - - public ImportFile(String pathname) { - super(pathname); - } - - public ImportFile(URI uri) { - super(uri); - } - - public ImportFile(File f) { - super(f.toURI()); - } - - /** - * Checks file by extension to determine if this file should be scanned for - * !import statements. - * - * @return True if this file should be scanned, else false. - */ - public boolean couldHaveImports() { - if (isDirectory()) { - return false; - } - String[] splitName = getName().split("\\."); - if (splitName.length > 1 && validExtensions.contains(splitName[splitName.length - 1])) { - return true; - } - return false; - } - - @Override - public ImportFile[] listFiles() { - String[] ss = list(); - if (ss == null) - return null; - int n = ss.length; - ImportFile[] fs = new ImportFile[n]; - for (int i = 0; i < n; i++) { - fs[i] = new ImportFile(this, ss[i]); - } - return fs; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScanner.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScanner.java deleted file mode 100644 index b061035..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScanner.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.scriptimport; - -import static com.gtnexus.appxpress.AppXpressConstants.IMPORT_FLAG; - -import java.io.Reader; -import java.util.Collections; -import java.util.HashSet; -import java.util.Scanner; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ImportScanner { - - private static final Pattern startOfBlockComment = Pattern.compile("/[\\*].*"); - private static final Pattern endOfBlockComment = Pattern.compile(".*[\\*]/"); - private static final Pattern singleLineComment = Pattern.compile("//.*"); - - public Set parseDoc(final Reader fileContents) { - final Set fileNames = new HashSet<>(); - try { - final Scanner scan = new Scanner(fileContents); - String line; - boolean lineIsInBlock = false; - while (scan.hasNextLine()) { - // TODO this logic is foobar. Clean this up! - line = scan.nextLine(); - Matcher startCommentMatcher = startOfBlockComment.matcher(line); - Matcher endCommentMatcher = endOfBlockComment.matcher(line); - Matcher singleLineCommentMatcher = singleLineComment.matcher(line); - if (startCommentMatcher.find()) { - lineIsInBlock = true; - } - if (lineIsInBlock || singleLineCommentMatcher.find()) { - fileNames.addAll(scanLine(line)); - } - if (endCommentMatcher.find()) { - lineIsInBlock = false; - } - if (!(lineIsInBlock || singleLineCommentMatcher.find() || !line.equals(""))) { - break; - } - } - scan.close(); - } catch (Exception e) { - e.printStackTrace(); - } - return fileNames; - } - - /** - * Looks through a line for the !import statement. If !import is found, adds the - * following word, which should be a name of a js script located in lib folder, - * and adds it to importFiles - * - * @param line - * Line of a file - */ - public Set scanLine(String line) { - if (line == null) { - throw new NullPointerException("Cannot scan null line"); - } - if (line.isEmpty()) { - return Collections.emptySet(); - } - final Set libFiles = new HashSet<>(); - line = line.replaceAll(",", " "); - if (line.contains(IMPORT_FLAG)) { - final String[] fileNames = line.split("\\s+"); - boolean importFlagFound = false; - for (String fileName : fileNames) { - if (importFlagFound && !fileName.isEmpty()) { - libFiles.add(fileName); - } - if (isImportFlag(fileName)) { - importFlagFound = true; - } - } - } - return libFiles; - } - - private boolean isImportFlag(String fileName) { - if (fileName.equals(IMPORT_FLAG)) { - return true; - } - if (fileName.length() >= 2) { - return fileName.substring(2, fileName.length()).equals(IMPORT_FLAG); - } - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportService.java b/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportService.java deleted file mode 100644 index 9fec772..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportService.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder.scriptimport; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import com.gtnexus.appxpress.commons.HasPrerequisite; -import com.gtnexus.appxpress.commons.file.FileService; -import com.gtnexus.appxpress.commons.file.LibResourceToPath; -import com.gtnexus.appxpress.exception.AppXpressException; - -/** - * Parses a file for !import statements - * - * @author Andrew Reynolds - * @author John Donovan - * @version 1.0 - * @date 8-27-2014 GT Nexus - */ -public class ImportService { - - private final ImportFile root; - private final ImportScanner importScanner; - private final FileService fs; - private final HasPrerequisite precondition; - private final Path libPath; - - public ImportService(final File root, final Path libPath) { - this.root = new ImportFile(root); - this.libPath = libPath; - this.importScanner = new ImportScanner(); - this.fs = new FileService(); - this.precondition = new HasPrerequisite() { - /** - * This precondition is here as a guard. Some File objects are created via - * manual appending of path Strings. This ensures we do not try to copy an - * object that does not exist. - */ - @Override - public boolean isMet(File f) { - return f != null && f.exists(); - } - }; - } - - /** - * Looks recursively through the file structure Searching through the file - * structure to find !import statements. It ignores zip, xml , and xsd files - * - * @param filePath - * File path to recursively search - * @throws AppXpressException - */ - public void scanAndImport() throws AppXpressException { - if (!root.isDirectory()) { - throw new AppXpressException( - root.getAbsolutePath() + " is invalid. filePath " + "must be a valid path to a directory"); - } - traverse(root); - } - - /** - * Recursively traverses - * - * @param f - */ - private void traverse(final ImportFile f) { - Set fileNamesForImport = new HashSet<>(); - for (ImportFile file : f.listFiles()) { - if (file.isDirectory()) { - traverse(file); - } else if (file.couldHaveImports()) { - fileNamesForImport.addAll(readInImports(file)); - } - } - if (fileNamesForImport.size() > 0) { - importFiles(fileNamesForImport, f); - } - } - - private Set readInImports(ImportFile file) { - try { - BufferedReader reader = new BufferedReader(new FileReader(file)); - return importScanner.parseDoc(reader); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - return Collections.emptySet(); - } - - /** - * Copies the set of files to a given destination - * - * @param filesToImport - * @param destinationDirectory - */ - private void importFiles(final Set filesToImport, final File destinationDirectory) { - System.out.println(filesToImport.size() + " import(s) directives found."); - try { - fs.copyFiles(filesToImport, new LibResourceToPath(libPath), destinationDirectory, precondition); - } catch (IOException e) { - System.err.println("Unable to import files!"); - } - } - -} \ No newline at end of file diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/PMDocGenCommand.java b/src/main/java/com/gtnexus/appxpress/pmdocgen/PMDocGenCommand.java deleted file mode 100644 index 689a890..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/PMDocGenCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gtnexus.appxpress.pmdocgen; - -import com.google.common.base.Preconditions; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.command.Command; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextFactory; -import com.gtnexus.appxpress.exception.AppXpressException; - -public class PMDocGenCommand implements Command { - - private String[] args; - private ContextFactory contextFactory; - - public PMDocGenCommand(String... args) { - Preconditions.checkNotNull(args); - this.args = args; - this.contextFactory = new ContextFactory(); - } - - @Override - public void execute() throws AppXpressException { - PlatformModuleDocumentGenerator pmdg = new PlatformModuleDocumentGenerator(); - AppXpressContext context; - try { - context = contextFactory.createContext(pmdg, args); - pmdg.generateDocs(context); - } catch (AppXpressException e) { - throw new AppXpressException("docgen has failed.", e); - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/PlatformModuleDocumentGenerator.java b/src/main/java/com/gtnexus/appxpress/pmdocgen/PlatformModuleDocumentGenerator.java deleted file mode 100644 index a7607d8..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/PlatformModuleDocumentGenerator.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.gtnexus.appxpress.pmdocgen; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Map; -import java.util.Set; - -import org.apache.poi.xssf.usermodel.XSSFWorkbook; - -import com.google.common.collect.ImmutableSet; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.options.CustomerOption; -import com.gtnexus.appxpress.cli.option.options.HelpOpt; -import com.gtnexus.appxpress.cli.option.options.LocalDirOpt; -import com.gtnexus.appxpress.cli.option.options.ModuleOption; -import com.gtnexus.appxpress.cli.option.options.SelectOption; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextBasedCleanUp; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.platform.module.ModulePointer; -import com.gtnexus.appxpress.platform.module.ModuleVO; -import com.gtnexus.appxpress.platform.module.interpretation.PlatformModuleInterpreter; -import com.gtnexus.appxpress.pmdocgen.cli.option.DocumentGeneratorOptions; - -/** - * Generates documentation for the given platform module. - * - * Currently only supporting excel, but is open to supporting other formats in - * the future. - * - * @author jdonovan - */ -public class PlatformModuleDocumentGenerator implements PMMCommandInfo { - - private static final String NAME = "pmdocgen"; - - public static final CLICommandOption helpOpt = new HelpOpt(); - public static final CLICommandOption customerOpt = new CustomerOption(); - public static final CLICommandOption moduleOpt = new ModuleOption(); - public static final CLICommandOption localDirOpt = new LocalDirOpt(); - public static final CLICommandOption selectOpt = new SelectOption(); - - private final WorkbookRenderer renderer; - - private static final Set options = new ImmutableSet.Builder().add(helpOpt) - .add(customerOpt).add(moduleOpt).add(localDirOpt).add(selectOpt).build(); - - public PlatformModuleDocumentGenerator() { - this.renderer = new WorkbookRenderer(); - } - - public void generateDocs(AppXpressContext context) throws AppXpressException { - attachCleanUpHook(context); - ModulePointer pointer = ModulePointer.make(context.getOptMap()); - PlatformModuleInterpreter interp = new PlatformModuleInterpreter(pointer); - ModuleVO vo = interp.interpret(); - XSSFWorkbook wb = renderer.render(vo); - File file = new File(fileName(context.getOptMap())); - try (FileOutputStream fileOut = new FileOutputStream(file)) { - wb.write(fileOut); - } catch (IOException e) { - throw new AppXpressException("Failed to write documentation to file.", e); - } - System.out.println("Success! Documentation written to " + file.toPath().toAbsolutePath().toString()); - } - - private void attachCleanUpHook(AppXpressContext ctx) { - Runtime.getRuntime().addShutdownHook(new Thread(new ContextBasedCleanUp<>(ctx))); - } - - private String fileName(Map optMap) { - String fileNameTemplate = "%s-%s-TechnicalSpecification.xlsx"; - return String.format(fileNameTemplate, optMap.get(customerOpt), optMap.get(moduleOpt)); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public String getHelpHeader() { - return ""; - } - - @Override - public String getHelpFooter() { - return ""; - } - - @Override - public Class getContextType() { - return DocumentGeneratorOptions.class; - } - - @Override - public Set getOptions() { - return options; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/DocumentGeneratorOptionInterpreter.java b/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/DocumentGeneratorOptionInterpreter.java deleted file mode 100644 index 486f26a..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/DocumentGeneratorOptionInterpreter.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.gtnexus.appxpress.pmdocgen.cli; - -import java.io.File; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.Select; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.CLICommandOptionInterpreter; -import com.gtnexus.appxpress.cli.option.CLIOptionInterpreter; -import com.gtnexus.appxpress.cli.option.ParsedOptions; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmdocgen.PlatformModuleDocumentGenerator; - -public class DocumentGeneratorOptionInterpreter extends CLICommandOptionInterpreter - implements CLIOptionInterpreter { - - private final AppXpressDirResolver resolver; - private final Select selector; - - public DocumentGeneratorOptionInterpreter(PMMCommandInfo app, SimpleShutdown shutdown, - ParsedOptions parsedOptions, PMProperties properties, Select selector, - AppXpressDirResolver resolver) { - super(app, shutdown, parsedOptions, properties); - this.resolver = resolver; - this.selector = selector; - } - - @Override - protected ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) - throws AppXpressException { - Path cwd = resolver.resovleCurrentDirectory(); - if (parsedOpts.hasOption(PlatformModuleDocumentGenerator.selectOpt)) { - doSelect(parsedOpts, cwd); - } - if (isCandidateForArgInjection(parsedOpts, cwd)) { - parsedOpts.put(PlatformModuleDocumentGenerator.customerOpt, cwd); - } - return parsedOpts; - } - - private boolean isCandidateForArgInjection(ParsedOptions parsedOpts, Path cwd) - throws AppXpressException { - return !parsedOpts.hasOption(PlatformModuleDocumentGenerator.customerOpt) - && isCustomerFolder(cwd, PlatformModuleDocumentGenerator.localDirOpt); - } - - private void doSelect(ParsedOptions parsedOpts, Path cwd) throws AppXpressException { - if (!isCustomerFolder(cwd, PlatformModuleDocumentGenerator.localDirOpt)) { - throw new AppXpressException("The select option must be run from a customer folder."); - } - Collection choices = getCandidates(cwd); - if (choices.isEmpty()) { - throw new AppXpressException("Nothing to select from!"); - } - File selection = selector.select(choices); - parsedOpts.put(PlatformModuleDocumentGenerator.moduleOpt, selection); - parsedOpts.put(PlatformModuleDocumentGenerator.customerOpt, cwd); - } - - private Collection getCandidates(Path dir) { - File[] files = dir.toFile().listFiles(FileFilterFactory.directoriesOnly()); - return Arrays.asList(files); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/option/DocumentGeneratorOptions.java b/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/option/DocumentGeneratorOptions.java deleted file mode 100644 index c3e255f..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmdocgen/cli/option/DocumentGeneratorOptions.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.gtnexus.appxpress.pmdocgen.cli.option; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; - -public class DocumentGeneratorOptions implements CLICommandOption { - - @Override - public String getLongName() { - return null; - } - - @Override - public String getFlag() { - return null; - } - - @Override - public Class getType() { - return null; - } - - @Override - public String getDescription() { - return null; - } - - @Override - public boolean hasArg() { - return false; - } - - @Override - public boolean isHelpFlag() { - return false; - } - - @Override - public String getMessage() { - return null; - } - - @Override - public boolean isAppXpressMandatory() { - return false; - } - - @Override - public boolean shouldBeOmitted() { - return false; - } - - @Override - public boolean isValid(String val) { - return false; - } - - @Override - public String getDefaultValue() { - return null; - } - - @Override - public boolean isStoreableProperty() { - return false; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/ExtractCommand.java b/src/main/java/com/gtnexus/appxpress/pmextractor/ExtractCommand.java deleted file mode 100644 index fa8fa88..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/ExtractCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.gtnexus.appxpress.pmextractor; - -import com.google.common.base.Preconditions; -import com.gtnexus.appxpress.commons.command.Command; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextFactory; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; - -public class ExtractCommand implements Command { - - private String[] args; - private ContextFactory contextFactory; - - public ExtractCommand(String... args) { - Preconditions.checkNotNull(args); - this.args = args; - this.contextFactory = new ContextFactory(); - } - - @Override - public void execute() throws AppXpressException { - PlatformModuleExtractor extractor = new PlatformModuleExtractor(); - AppXpressContext context; - try { - context = contextFactory.createContext(extractor, args); - extractor.extract(context); - } catch (AppXpressException e) { - throw new AppXpressException("extract has failed.", e); - } - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/PlatformModuleExtractor.java b/src/main/java/com/gtnexus/appxpress/pmextractor/PlatformModuleExtractor.java deleted file mode 100644 index 2219a86..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/PlatformModuleExtractor.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.gtnexus.appxpress.pmextractor; - -import java.util.Set; - -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.commons.Mapper; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.context.AppXpressContext; -import com.gtnexus.appxpress.context.ContextBasedCleanUp; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; -import com.gtnexus.appxpress.pmextractor.gitmap.GitMapper; - -/** - * - * @author jdonovan - * - */ -public class PlatformModuleExtractor implements PMMCommandInfo { - - private static final String NAME = "pmextractor"; - - public PlatformModuleExtractor() { - } - - public void extract(AppXpressContext context) throws AppXpressException { - attachCleanUpHook(context); - Mapper tool = GitMapper.createMapper(context); - try { - tool.doMapping(); - System.out.println("Success!"); - } catch (AppXpressException e) { - context.setTerminatedRegulary(false); - throw new AppXpressException("Failure when running pmextractor.", e); - } - } - - private void attachCleanUpHook(AppXpressContext ctx) { - Runtime.getRuntime().addShutdownHook(new Thread(new ContextBasedCleanUp<>(ctx))); - } - - @Override - public String getName() { - return NAME; - } - - @Override - public String getHelpHeader() { - return ""; - } - - @Override - public String getHelpFooter() { - return ""; - } - - @Override - public Class getContextType() { - return ExtractorOption.class; - } - - @Override - public Set getOptions() { - return ExtractorOption.getAllOptions(); - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOption.java b/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOption.java deleted file mode 100644 index 73954e3..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOption.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.gtnexus.appxpress.pmextractor.cli; - -import java.util.EnumSet; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import com.gtnexus.appxpress.cli.asker.ValidityProvider; -import com.gtnexus.appxpress.cli.option.CLICommandOption; -import com.gtnexus.appxpress.cli.option.OptionMessageProvider; - -/** - * Enumeration of options that can be stored in the Properties file or read in - * from the CLI. - */ -public enum ExtractorOption implements CLICommandOption { - - HELP("h", "help", String.class, "Display usage for this tool", false, false, null), PLATFORM_ZIP("pz", - "platformZip", String.class, "Exported Platform Module Name", true, true, null), LOCAL_DIR("ld", "localDir", - String.class, "Relative Path of GIT staging folder", true, true, null), CUSTOMER("c", "customer", - String.class, "Customer of Platform Module", true, true, null), SELECT("s", "select", - Integer.class, "Select platform from the folders present in the cwd.", false, false, - null), MODULE("m", "module", String.class, "Platform Module that is being exported", - true, true, null), OVERWRITE_SCRIPTS("os", "overwriteScripts", - Boolean.class, "If Y -> overwriteScripts = true", true, false, - "Y"), OVERWRITE_FEF("of", "overwriteFef", Boolean.class, - "If Y -> overwriteFEF = true", true, false, "Y"); - - private final String flag; - private final String longName; - private final Class type; - private final boolean hasArg; - private final boolean isMandatory; - private final String defaultValue; - private final String description; - private static final OptionMessageProvider msgProvider = new OptionMessageProvider(); - private static final ValidityProvider validityProvider = new ValidityProvider(); - - private final static Set allOptions = new ImmutableSet.Builder() - .addAll(EnumSet.allOf(ExtractorOption.class)).build(); - - /** - * - * @param longName - * The name of this ExtractorOption. - * @param type - * The ExtractorOption type. - * @param description - * @param isMandatory - * @param defaulValue - */ - private ExtractorOption(String flag, String longName, Class type, String description, boolean hasArg, - boolean isMandatory, String defaulValue) { - this.flag = flag; - this.longName = longName; - this.type = type; - this.hasArg = hasArg; - this.description = description; - this.isMandatory = isMandatory; - this.defaultValue = defaulValue; - } - - @Override - public String toString() { - return longName; - } - - @Override - public String getLongName() { - return longName; - } - - @Override - public Class getType() { - return type; - } - - @Override - public String getMessage() { - return msgProvider.getMessage(type, longName); - } - - @Override - public String getDescription() { - return description; - } - - @Override - public boolean hasArg() { - return hasArg; - } - - @Override - public boolean isAppXpressMandatory() { - return isMandatory; - } - - @Override - public boolean shouldBeOmitted() { - return !isMandatory && defaultValue == null; - } - - /** - * @return the default value for non-mandatory options. - * @throws java.lang.UnsupportedOperationException - * if this method is called on a mandatory option. - */ - @Override - public String getDefaultValue() { - if (this.isMandatory) { - throw new UnsupportedOperationException(this.longName + " is a mandatory field, and must come from " - + "user args or properties. There is no default value."); - } - return defaultValue; - } - - /** - * Checks to see if the val supplies is a valid argument according to this - * option's type. - * - * @param val - * @return - */ - @Override - public boolean isValid(String val) { - return validityProvider.isValid(val, type); - } - - @Override - public String getFlag() { - return flag; - } - - @Override - public boolean isStoreableProperty() { - if (this == LOCAL_DIR) { - return true; - } - return false; - } - - @Override - public boolean isHelpFlag() { - return this.equals(HELP); - } - - public static Set getAllOptions() { - return allOptions; - } - -} diff --git a/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOptionInterpreter.java b/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOptionInterpreter.java deleted file mode 100644 index 4cd3a2f..0000000 --- a/src/main/java/com/gtnexus/appxpress/pmextractor/cli/ExtractorOptionInterpreter.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.gtnexus.appxpress.pmextractor.cli; - -import static com.gtnexus.appxpress.AppXpressConstants.ZIP_EXTENSION; - -import java.io.File; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collection; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.Select; -import com.gtnexus.appxpress.cli.option.CLICommandOptionInterpreter; -import com.gtnexus.appxpress.cli.option.CLIOptionInterpreter; -import com.gtnexus.appxpress.cli.option.ParsedOptions; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.exception.PMExtractorException; - -public class ExtractorOptionInterpreter extends CLICommandOptionInterpreter - implements CLIOptionInterpreter { - - private final Select selector; - private AppXpressDirResolver resolver; - - public ExtractorOptionInterpreter(PMMCommandInfo app, SimpleShutdown shutdown, - ParsedOptions parsedOptions, PMProperties properties, Select selector, - AppXpressDirResolver resolver) { - super(app, shutdown, parsedOptions, properties); - this.selector = selector; - this.resolver = resolver; - } - - @Override - public ParsedOptions performCustomInterpretation(ParsedOptions parsedOpts) - throws AppXpressException { - Path cwd = resolver.resovleCurrentDirectory(); - if (parsedOpts.hasOption(ExtractorOption.SELECT)) { - Collection choices = getCandidates(cwd); - if (choices.isEmpty()) { - throw new PMExtractorException("There are no .zip's to select from!"); - } - File selection = selector.select(choices); - parsedOpts.put(ExtractorOption.PLATFORM_ZIP, selection); - } - if (isCandidateForArgInjection(parsedOpts, cwd)) { - parsedOpts.put(ExtractorOption.CUSTOMER, cwd); - } - return parsedOpts; - } - - private boolean isCandidateForArgInjection(ParsedOptions parsedOpts, Path cwd) - throws AppXpressException { - return !parsedOpts.hasOption(ExtractorOption.CUSTOMER) && isCustomerFolder(cwd, ExtractorOption.LOCAL_DIR); - } - - private Collection getCandidates(Path dir) { - File[] files = dir.toFile().listFiles(FileFilterFactory.endsWith(ZIP_EXTENSION)); - return Arrays.asList(files); - } -} diff --git a/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java b/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java index 5c1d8b1..f363f4a 100644 --- a/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java +++ b/src/test/java/com/gtnexus/appxpress/AppXpressExceptionTest.java @@ -4,22 +4,22 @@ import org.junit.Test; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; public class AppXpressExceptionTest { @Test public void testGetMessage() { StringBuilder sb = new StringBuilder(); - String[] ss = { "1", "2", "3", "4" }; + String[] ss = {"1", "2", "3", "4" }; for (String s : ss) { sb.append(s); sb.append("\n"); } String expected = sb.toString().trim(); - AppXpressException root = new AppXpressException(ss[ss.length - 1]); + SubCommandException root = new SubCommandException(ss[ss.length - 1]); for (int i = ss.length - 2; i >= 0; i--) { - root = new AppXpressException(ss[i], root); + root = new SubCommandException(ss[i], root); } String actual = root.getAppXpressMessage(); assertEquals(expected, actual); diff --git a/src/test/java/com/gtnexus/appxpress/cli/option/BuilderOptionInterpreterTest.java b/src/test/java/com/gtnexus/appxpress/cli/option/BuilderOptionInterpreterTest.java deleted file mode 100644 index 159dce2..0000000 --- a/src/test/java/com/gtnexus/appxpress/cli/option/BuilderOptionInterpreterTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import static org.junit.Assert.fail; - -import java.util.HashMap; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import com.gtnexus.appxpress.AppXpressDirResolver; -import com.gtnexus.appxpress.cli.FileSelector; -import com.gtnexus.appxpress.commons.command.PMMCommandInfo; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.commons.runtime.SimpleShutdown; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOptionInterpreter; - -@RunWith(MockitoJUnitRunner.class) -public class BuilderOptionInterpreterTest { - - @Mock - PMMCommandInfo app; - @Mock - SimpleShutdown shutdown; - @Mock - PMProperties properties; - @Mock - FileSelector selector; - - @Mock - AppXpressDirResolver resolver; - - BuilderOptionInterpreter interpreter; - HashMap optMap = new HashMap<>(); - - @Before - public void setup() { - - } - - @Test(expected = NullPointerException.class) - public void testPerformCustomInterpretationWithNull() throws Exception { - interpreter.performCustomInterpretation(null); - } - - @Ignore("Not yet implemented") - @Test - public void testPerformCustomInterpretationWithoutSPFlag() throws AppXpressException { - // ParsedOptions parsedOptions = new ParsedOptions<>( - // new Options(), new HashMap(), - // EnumSet.allOf(BuilderOption.class)); - // BuilderOptionInterpreter interpeter = new BuilderOptionInterpreter(app, - // shutdown, parsedOptions, properties, selector, resolver); - fail("unimplemented"); - } - - @Ignore("Not yet implemented") - @Test - public void testPerformCustomInterpretationWithSPFlag() throws AppXpressException { - - } -} diff --git a/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java b/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java new file mode 100644 index 0000000..fb65a29 --- /dev/null +++ b/src/test/java/com/gtnexus/appxpress/cli/option/CLICommandOptionParserTest.java @@ -0,0 +1,39 @@ +package com.gtnexus.appxpress.cli.option; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.EnumSet; +import java.util.Map; +import java.util.Set; + +import org.junit.Test; + +import com.google.common.collect.ImmutableSet; +import com.gtnexus.appxpress.pmextractor.cli.DummyOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOptionParser; +import com.gtnexus.pmm.api.v100.command.SubCommandException; + +public class CLICommandOptionParserTest { + + private final Set optSet = new ImmutableSet.Builder().add(DummyOption.DUMMY).build(); + private final CommandOptionParser parser = CommandOptionParser.createParser(optSet); + + @Test + public void testParse() throws Exception { + Map parsedOpts = parser.parse(new String[] {"-Dummy"}); + assertTrue(parsedOpts.containsKey(DummyOption.DUMMY)); + } + + @Test(expected = SubCommandException.class) + public void testParseWithInvalidOpt() throws Exception { + parser.parse(new String[] {"-invalidOpt"}); + } + + @Test + public void testGetCliOptionSet() throws Exception { + assertEquals(EnumSet.allOf(DummyOption.class), parser.getCliOptionSet()); + } + +} diff --git a/src/test/java/com/gtnexus/appxpress/cli/option/CLIOptionParserTest.java b/src/test/java/com/gtnexus/appxpress/cli/option/CLIOptionParserTest.java deleted file mode 100644 index 6ba5462..0000000 --- a/src/test/java/com/gtnexus/appxpress/cli/option/CLIOptionParserTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.gtnexus.appxpress.cli.option; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.EnumSet; -import java.util.Set; - -import org.junit.Before; -import org.junit.Test; - -import com.google.common.collect.ImmutableSet; -import com.gtnexus.appxpress.exception.AppXpressException; -import com.gtnexus.appxpress.pmextractor.cli.DummyOption; - -public class CLIOptionParserTest { - - CLIOptionParser cli; - String appName = "ParserTest"; - Set optSet = new ImmutableSet.Builder().add(DummyOption.DUMMY).build(); - - @Before - public void setUp() { - String[] args = { "-Dummy" }; - cli = CLIOptionParser.createParser(optSet, args); - } - - @Test(expected = NullPointerException.class) - public void testWithNullArgs() { - new CLIOptionParser<>(null, null, null); - } - - @Test - public void testParse() throws Exception { - ParsedOptions parsedOpts = cli.parse(); - assertTrue(parsedOpts.hasOption(DummyOption.DUMMY)); - } - - @Test(expected = AppXpressException.class) - public void testParseWithInvalidOpt() throws Exception { - String[] args = { "-invalidOpt" }; - CLIOptionParser cli2 = CLIOptionParser.createParser(optSet, args); - cli2.parse(); - } - - @Test - public void testGetCliOptionSet() throws Exception { - assertEquals(EnumSet.allOf(DummyOption.class), cli.getCliOptionSet()); - } - -} diff --git a/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java b/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java index b33ecde..a7dda90 100644 --- a/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java +++ b/src/test/java/com/gtnexus/appxpress/commons/PMPropertiesTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.properties.PMProperties; +import com.gtnexus.pmm.app.common.properties.PMProperties; public class PMPropertiesTest { diff --git a/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java b/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java index f2e6caf..66c7df3 100644 --- a/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/CopyDirVisitorTest.java @@ -13,7 +13,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.file.CopyDirVisitor; +import com.gtnexus.pmm.app.common.file.CopyDirVisitor; public class CopyDirVisitorTest { diff --git a/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java b/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java index 8827ee8..bac3bbb 100644 --- a/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/DeleteDirVisitorTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.file.DeleteDirVisitor; +import com.gtnexus.pmm.app.common.file.DeleteDirVisitor; public class DeleteDirVisitorTest { diff --git a/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java b/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java index e4abb49..bd7c888 100644 --- a/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/FileServiceTest.java @@ -16,15 +16,16 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.HasPrerequisite; -import com.gtnexus.appxpress.commons.file.FileService; +import com.gtnexus.pmm.api.v100.service.FileService; +import com.gtnexus.pmm.app.common.HasPrerequisite; +import com.gtnexus.pmm.app.service.FileServiceImpl; public class FileServiceTest { @Rule public TemporaryFolder tmp = new TemporaryFolder(); - private FileService fs = new FileService(); + private FileService fs = new FileServiceImpl(); @Test public void testPrependToName() throws IOException { diff --git a/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java b/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java index 1e1b559..a28e9bb 100644 --- a/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/filter/ChainedAndTest.java @@ -9,8 +9,8 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.file.filter.ChainedAnd; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; +import com.gtnexus.pmm.app.common.file.filter.ChainedAnd; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; public class ChainedAndTest { diff --git a/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java b/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java index 12c5920..6b58110 100644 --- a/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/filter/ChainedOrTest.java @@ -9,8 +9,8 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.file.filter.ChainedOr; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; +import com.gtnexus.pmm.app.common.file.filter.ChainedOr; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; public class ChainedOrTest { diff --git a/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java b/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java index 8b22d38..3b6bfce 100644 --- a/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java +++ b/src/test/java/com/gtnexus/appxpress/file/filter/FileFilterFactoryTest.java @@ -12,7 +12,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; -import com.gtnexus.appxpress.commons.file.filter.FileFilterFactory; +import com.gtnexus.pmm.app.common.file.filter.FileFilterFactory; public class FileFilterFactoryTest { diff --git a/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java b/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java index 5224b04..074f4ac 100644 --- a/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java +++ b/src/test/java/com/gtnexus/appxpress/platform/module/model/platformmodule/PlatformModuleTest.java @@ -13,13 +13,15 @@ import org.junit.Test; +import com.gtnexus.pmm.app.platform.module.model.platformmodule.PlatformModuleXml; + public class PlatformModuleTest { @Test public void testUnmarshall() throws FileNotFoundException, JAXBException { File file = new File("src/test/resources/PlatformModule.xml"); FileReader reader = new FileReader(file); - JAXBContext context = JAXBContext.newInstance("com.gtnexus.appxpress.platform.module.model.platformmodule"); + JAXBContext context = JAXBContext.newInstance("com.gtnexus.pmm.platform.module.model.platformmodule"); Unmarshaller unmarshaller = context.createUnmarshaller(); PlatformModuleXml platformMod = (PlatformModuleXml) JAXBIntrospector.getValue(unmarshaller.unmarshal(reader)); assertNotNull(platformMod); diff --git a/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilderTest.java b/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilderTest.java deleted file mode 100644 index 977aa02..0000000 --- a/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformModuleBuilderTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.gtnexus.appxpress.pmbuilder; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -import com.gtnexus.appxpress.pmbuilder.cli.BuilderOption; - -public class PlatformModuleBuilderTest { - - @Test - public void testGetContextType() { - PlatformModuleBuilder pmb = new PlatformModuleBuilder(); - Class type = pmb.getContextType(); - assertEquals(type, BuilderOption.HELP.getClass()); - String className = type.getName(); - assertTrue("ClassName should have been BuilderOption but was " + className, - className.endsWith("BuilderOption")); - } - -} diff --git a/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java b/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java index fc75f61..c8a1c0d 100644 --- a/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java +++ b/src/test/java/com/gtnexus/appxpress/pmbuilder/PlatformSelectorTest.java @@ -11,8 +11,8 @@ import org.mockito.Mockito; import com.gtnexus.appxpress.NullOutputStream; -import com.gtnexus.appxpress.cli.FileSelector; -import com.gtnexus.appxpress.cli.asker.BoundIntegerAsker; +import com.gtnexus.pmm.api.v100.cli.FileSelector; +import com.gtnexus.pmm.api.v100.cli.prompt.BoundIntegerAsker; public class PlatformSelectorTest { @@ -25,7 +25,7 @@ public void testSelect() { files[i] = new File("File" + i); } BoundIntegerAsker asker = Mockito.mock(BoundIntegerAsker.class); - Mockito.when(asker.ask(Matchers.anyString())).thenReturn(1); + Mockito.when(asker.prompt(Matchers.anyString())).thenReturn(1); out = new PrintStream(new NullOutputStream()); FileSelector selector = new FileSelector(asker); File f = selector.select(Arrays.asList(files)); diff --git a/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java b/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java index bbd1afe..53d3667 100644 --- a/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java +++ b/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportFileTest.java @@ -10,6 +10,8 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; +import com.gtnexus.pmm.app.build.scriptimport.ImportFile; + public class ImportFileTest { @Rule diff --git a/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java b/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java index 20b7f43..410d96d 100644 --- a/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java +++ b/src/test/java/com/gtnexus/appxpress/pmbuilder/scriptimport/ImportScannerTest.java @@ -7,6 +7,8 @@ import org.junit.Test; +import com.gtnexus.pmm.app.build.scriptimport.ImportScanner; + public class ImportScannerTest { @Test diff --git a/src/test/java/com/gtnexus/appxpress/pmextractor/ArgsAndPropertiesConsolidatorTest.java b/src/test/java/com/gtnexus/appxpress/pmextractor/ArgsAndPropertiesConsolidatorTest.java deleted file mode 100644 index 3dc2bdd..0000000 --- a/src/test/java/com/gtnexus/appxpress/pmextractor/ArgsAndPropertiesConsolidatorTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.gtnexus.appxpress.pmextractor; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.InputStream; -import java.io.PrintStream; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.gtnexus.appxpress.NullOutputStream; -import com.gtnexus.appxpress.cli.CLIOptsAndPropConsolidator; -import com.gtnexus.appxpress.commons.properties.PMProperties; -import com.gtnexus.appxpress.pmextractor.cli.ExtractorOption; - -/** - * Created by jjdonov on 9/29/14. - */ -public class ArgsAndPropertiesConsolidatorTest { - - private static Set optSet; - private Map mandatoryFieldsAndVals; - private static Set allNonOmmitable; - - @BeforeClass - public static void setup() { - optSet = EnumSet.allOf(ExtractorOption.class); - } - - @Before - public void before() { - mandatoryFieldsAndVals = new HashMap<>(); - mandatoryFieldsAndVals.put(ExtractorOption.PLATFORM_ZIP, "arg_myZip"); - mandatoryFieldsAndVals.put(ExtractorOption.LOCAL_DIR, "arg_myLocalDir"); - mandatoryFieldsAndVals.put(ExtractorOption.CUSTOMER, "arg_myCustomer"); - mandatoryFieldsAndVals.put(ExtractorOption.MODULE, "arg_myPlatform"); - allNonOmmitable = EnumSet.allOf(ExtractorOption.class); - allNonOmmitable.remove(ExtractorOption.HELP); - } - - @Test - public void testWithArgsAndNullProps() { - Map args = mandatoryFieldsAndVals; - PMProperties properties = new PMProperties(new Properties(), new File("")); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(args, optSet, - properties, inputStreamFrom(), new PrintStream(new NullOutputStream())); - Map consolidated = consolidator.consolidate(); - for (ExtractorOption option : allNonOmmitable) { - if (!option.equals(ExtractorOption.SELECT)) { - assertNotNull(option.toString() + " is missing!", consolidated.get(option)); - assertTrue(option.getLongName() + " -> Option value was " + consolidated.get(option), - consolidated.get(option).startsWith("arg_") - || consolidated.get(option).equals(option.getDefaultValue())); - } - } - } - - @Test - public void testWithArgsAndProps() { - mandatoryFieldsAndVals.remove(ExtractorOption.LOCAL_DIR); - mandatoryFieldsAndVals.remove(ExtractorOption.MODULE); - Map args = mandatoryFieldsAndVals; - PMProperties properties = new PMProperties(new Properties(), new File("")); - properties.put(ExtractorOption.LOCAL_DIR.toString(), "prop_local_dir"); - properties.put(ExtractorOption.MODULE.toString(), "prop_platform"); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(args, optSet, - properties, inputStreamFrom("arg_customer", "arg_platform"), new PrintStream(new NullOutputStream())); - Map consolidated = consolidator.consolidate(); - for (ExtractorOption option : allNonOmmitable) { - if (option.equals(ExtractorOption.LOCAL_DIR)) { - assertTrue("The option was " + consolidated.get(option), consolidated.get(option).startsWith("prop_")); - } else if (!option.equals(ExtractorOption.SELECT)) { - assertNotNull(option.toString() + " is missing!", consolidated.get(option)); - assertTrue(consolidated.get(option) + " does not start with arg_.", - consolidated.get(option).startsWith("arg_") - || consolidated.get(option).equals(option.getDefaultValue())); - } - } - } - - @Test - public void testWithArgsPropsAndInputStream() { - mandatoryFieldsAndVals.remove(ExtractorOption.LOCAL_DIR); - Map args = mandatoryFieldsAndVals; - PMProperties properties = new PMProperties(new Properties(), new File("")); - properties.put(ExtractorOption.MODULE.toString(), "prop_platform"); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(args, optSet, - properties, inputStreamFrom("some_local_dir", "Y"), new PrintStream(new NullOutputStream())); - Map consolidated = consolidator.consolidate(); - assertTrue(consolidated.get(ExtractorOption.LOCAL_DIR).equals("some_local_dir")); - } - - @Test - public void testDefaultValForOptional() { - Map args = mandatoryFieldsAndVals; - PMProperties properties = new PMProperties(new Properties(), new File("")); - properties.put(ExtractorOption.MODULE.toString(), "prop_platform"); - CLIOptsAndPropConsolidator consolidator = new CLIOptsAndPropConsolidator<>(args, optSet, - properties, inputStreamFrom("some_local_dir", "Y"), new PrintStream(new NullOutputStream())); - Map consolidated = consolidator.consolidate(); - assertTrue(consolidated.get(ExtractorOption.OVERWRITE_FEF).equals("Y")); - } - - /** - * Creates an InputStream from strings, to fake i/o. - * - * @param strings - * @return - */ - private InputStream inputStreamFrom(String... strings) { - String separator = System.getProperty("line.separator"); - StringBuilder sb = new StringBuilder(); - for (String s : strings) { - sb.append(s.replaceAll(separator, " ").trim()).append(separator); - } - return new ByteArrayInputStream(sb.toString().getBytes()); - } - -} diff --git a/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java b/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java index f13d303..abf44cb 100644 --- a/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java +++ b/src/test/java/com/gtnexus/appxpress/pmextractor/DirectoryHelperTest.java @@ -6,8 +6,8 @@ import org.junit.Test; -import com.gtnexus.appxpress.commons.DirectoryHelper; -import com.gtnexus.appxpress.exception.AppXpressException; +import com.gtnexus.pmm.api.v100.command.SubCommandException; +import com.gtnexus.pmm.app.manager.DirectoryHelper; /** * Created by jjdonov on 9/29/14. @@ -15,8 +15,8 @@ @Deprecated public class DirectoryHelperTest { - @Test(expected = AppXpressException.class) - public void testWithoutEnsuring() throws AppXpressException { + @Test(expected = SubCommandException.class) + public void testWithoutEnsuring() throws SubCommandException { DirectoryHelper directoryHelper = new DirectoryHelper("test"); directoryHelper.getPmProperties(); } @@ -30,7 +30,7 @@ public void testWithHomeDirectory() { if (propFile == null || !propFile.exists()) { fail("Property file does not exist"); } - } catch (AppXpressException e) { + } catch (SubCommandException e) { fail("Exception when ensuring\n" + e.getMessage()); } } diff --git a/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java b/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java index ef0ff34..53647ee 100644 --- a/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java +++ b/src/test/java/com/gtnexus/appxpress/pmextractor/cli/DummyOption.java @@ -1,8 +1,8 @@ package com.gtnexus.appxpress.pmextractor.cli; -import com.gtnexus.appxpress.cli.option.CLIOption; +import com.gtnexus.pmm.api.v100.cli.option.CommandOption; -public enum DummyOption implements CLIOption { +public enum DummyOption implements CommandOption { DUMMY; @@ -31,9 +31,4 @@ public String getFlag() { return "d"; } - @Override - public boolean isHelpFlag() { - return false; - } - }