diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index e63507ad..00000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -### Describe the bug - -A clear and concise description of what the bug is. - -### Steps To Reproduce - -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -### Observed behavior - -Describe what you saw and why you think it's a bug? - -### Expected behavior - -A clear and concise description of what you expected to happen. - -### Screenshots - -If applicable, add screenshots to help explain your problem. - -### Environment (please complete the following information): - -- OS: [e.g. macOS 15.1 | Windows 11] - - Version of Java - - Version of Maven - - Version of Gradle - -### Additional context - -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 5df86d28..00000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: '' -assignees: '' - ---- - -### Is your feature request related to a problem? Please describe - -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -### Describe the solution you'd like - -A clear and concise description of what you want to happen. - -### Describe alternatives you've considered - -A clear and concise description of any alternative solutions or features you've considered. - -### Additional context - -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/user_story.md b/.github/ISSUE_TEMPLATE/user_story.md deleted file mode 100644 index 33bf9b34..00000000 --- a/.github/ISSUE_TEMPLATE/user_story.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -name: User Story -about: Use this for creating User Stories -title: '' -labels: '' -assignees: '' - ---- - -### Feature - -**As a** [role] -**I need** [functionality] -**So that** [benefit] - -### Details & Assumptions - -- document what you know here... - -### Acceptance Criteria - -```gherkin -Given [some initial state] -When [some event] -Then [some measurable outcome] -``` diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index bec85d1e..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Codeanalyzer CI - -on: - push: - branches: - - main - -permissions: - contents: write - -jobs: - build-and-package: - runs-on: ubuntu-latest - - env: - JAVA_HOME: ${{ github.workspace }}/graalvm-ce-java11-22.3.3 - - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - persist-credentials: true - - - name: Set up JDK 11 from GraalVM - run: | - echo "${{ env.JAVA_HOME }}/bin" >> $GITHUB_PATH - wget https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.3/graalvm-ce-java11-linux-amd64-22.3.3.tar.gz - tar -xvzf graalvm-ce-java11-linux-amd64-22.3.3.tar.gz - ${{ env.JAVA_HOME }}/bin/gu install native-image - - - name: Make gradlew executable - run: chmod +x ./gradlew - - - name: Build with Gradle - run: ./gradlew clean fatJar - - - name: Determine new tag - id: newtag - run: | - VERSION=$(java -jar build/libs/*.jar --version | awk '{print $1}') - TAG="v$VERSION" - echo "tag=$TAG" >> $GITHUB_OUTPUT - - - name: Create Git Tag - run: | - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git tag ${{ steps.newtag.outputs.tag }} - git push origin ${{ steps.newtag.outputs.tag }} - - - name: Publish Release - uses: softprops/action-gh-release@v1 - with: - files: build/libs/*.jar - tag_name: ${{ steps.newtag.outputs.tag }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index a3e91d4d..1f45f57c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -/* + /* Copyright IBM Corporation 2023, 2024 Licensed under the Apache Public License 2.0, Version 2.0 (the "License"); diff --git a/gradle.properties b/gradle.properties index 1d50c83d..13794c20 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=2.1.0 +version=2.2.0 diff --git a/src/main/java/com/ibm/cldk/CodeAnalyzer.java b/src/main/java/com/ibm/cldk/CodeAnalyzer.java index 6ad44f2d..2490e57d 100644 --- a/src/main/java/com/ibm/cldk/CodeAnalyzer.java +++ b/src/main/java/com/ibm/cldk/CodeAnalyzer.java @@ -91,6 +91,7 @@ public class CodeAnalyzer implements Runnable { public static Gson gson = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .setPrettyPrinting() + .serializeNulls() // Fix for issue #108 .disableHtmlEscaping() .create(); diff --git a/src/main/java/com/ibm/cldk/SymbolTable.java b/src/main/java/com/ibm/cldk/SymbolTable.java index 1de23f14..521144c4 100644 --- a/src/main/java/com/ibm/cldk/SymbolTable.java +++ b/src/main/java/com/ibm/cldk/SymbolTable.java @@ -27,6 +27,9 @@ import com.github.javaparser.utils.SourceRoot; import com.google.common.collect.Table; import com.google.common.collect.Tables; +import com.ibm.cldk.javaee.CRUDFinderFactory; +import com.ibm.cldk.javaee.utils.enums.CRUDOperationType; +import com.ibm.cldk.javaee.utils.enums.CRUDQueryType; import com.ibm.cldk.entities.*; import com.ibm.cldk.utils.Log; import org.apache.commons.lang3.tuple.Pair; @@ -409,6 +412,18 @@ private static Pair processCallableDeclaration(CallableDeclara callableNode.setAccessedFields(getAccessedFields(body, classFields, typeName)); callableNode.setCallSites(getCallSites(body)); + callableNode.setCrudOperations( + callableNode.getCallSites().stream() + .map(CallSite::getCrudOperation) + .filter(Objects::nonNull) + .collect(Collectors.toList()) + ); + callableNode.setCrudQueries( + callableNode.getCallSites().stream() + .map(CallSite::getCrudQuery) + .filter(Objects::nonNull) + .collect(Collectors.toList()) + ); callableNode.setVariableDeclarations(getVariableDeclarations(body)); callableNode.setCyclomaticComplexity(getCyclomaticComplexity(callableDecl)); @@ -420,16 +435,19 @@ private static boolean isEntryPointMethod(CallableDeclaration callableDecl) { return isServletEntrypointMethod(callableDecl) || isJaxRsEntrypointMethod(callableDecl) || isSpringEntrypointMethod(callableDecl) | isStrutsEntryPointMethod(callableDecl); } + @SuppressWarnings("unchecked") private static boolean isServletEntrypointMethod(CallableDeclaration callableDecl) { return ((NodeList) callableDecl.getParameters()).stream() .anyMatch(parameter -> parameter.getType().asString().contains("HttpServletRequest") || parameter.getType().asString().contains("HttpServletResponse")) && callableDecl.getAnnotations().stream().anyMatch(a -> a.toString().contains("Override")); } + @SuppressWarnings("unchecked") private static boolean isJaxRsEntrypointMethod(CallableDeclaration callableDecl) { return callableDecl.getAnnotations().stream().anyMatch(a -> a.toString().contains("POST") || a.toString().contains("PUT") || a.toString().contains("GET") || a.toString().contains("HEAD") || a.toString().contains("DELETE")); } + @SuppressWarnings("unchecked") private static boolean isSpringEntrypointMethod(CallableDeclaration callableDecl) { return callableDecl.getAnnotations().stream().anyMatch(a -> a.toString().contains("GetMapping") || @@ -455,10 +473,11 @@ private static boolean isSpringEntrypointMethod(CallableDeclaration callableDecl ); } + @SuppressWarnings("unchecked") private static boolean isStrutsEntryPointMethod(CallableDeclaration callableDecl) { // First check if this method is in a Struts Action class Optional parentNode = callableDecl.getParentNode(); - if (!parentNode.isPresent() || !(parentNode.get() instanceof ClassOrInterfaceDeclaration)) { + if (parentNode.isEmpty() || !(parentNode.get() instanceof ClassOrInterfaceDeclaration)) { return false; } @@ -631,6 +650,7 @@ private static List getAccessedFields(Optional callableBody, * @param callableBody callable to compute call-site information for * @return list of call sites */ + @SuppressWarnings({"OptionalUsedAsFieldOrParameterType"}) private static List getCallSites(Optional callableBody) { List callSites = new ArrayList<>(); if (callableBody.isEmpty()) { @@ -680,8 +700,31 @@ private static List getCallSites(Optional callableBody) { } // resolve arguments of the method call to types List arguments = methodCallExpr.getArguments().stream().map(SymbolTable::resolveExpression).collect(Collectors.toList()); + // Get argument string from the callsite + List listOfArgumentStrings = methodCallExpr.getArguments().stream().map(Expression::toString).collect(Collectors.toList()); + // Determine if this call site is potentially a CRUD operation. + CRUDOperation crudOperation = null; + Optional crudOperationType = findCRUDOperation(declaringType, methodCallExpr.getNameAsString()); + if (crudOperationType.isPresent()) { + // We found a CRUD operation, so we need to populate the details of the call site this CRUD operation. + int lineNumber = methodCallExpr.getRange().isPresent() ? methodCallExpr.getRange().get().begin.line : -1; + crudOperation = new CRUDOperation(); + crudOperation.setLineNumber(lineNumber); + crudOperation.setOperationType(crudOperationType.get()); + } + // Determine if this call site is potentially a CRUD query. + CRUDQuery crudQuery = null; + Optional crudQueryType = findCRUDQuery(declaringType, methodCallExpr.getNameAsString(), Optional.of(listOfArgumentStrings)); + if (crudQueryType.isPresent()) { + // We found a CRUD query, so we need to populate the details of the call site this CRUD query. + int lineNumber = methodCallExpr.getRange().isPresent() ? methodCallExpr.getRange().get().begin.line : -1; + crudQuery = new CRUDQuery(); + crudQuery.setLineNumber(lineNumber); + crudQuery.setQueryType(crudQueryType.get()); + crudQuery.setQueryArguments(listOfArgumentStrings); + } // add a new call site object - callSites.add(createCallSite(methodCallExpr, methodCallExpr.getNameAsString(), receiverName, declaringType, arguments, returnType, calleeSignature, isStaticCall, false, accessSpecifier)); + callSites.add(createCallSite(methodCallExpr, methodCallExpr.getNameAsString(), receiverName, declaringType, arguments, returnType, calleeSignature, isStaticCall, false, crudOperation, crudQuery, accessSpecifier)); } for (ObjectCreationExpr objectCreationExpr : callableBody.get().findAll(ObjectCreationExpr.class)) { @@ -700,11 +743,52 @@ private static List getCallSites(Optional callableBody) { } // add a new call site object - callSites.add(createCallSite(objectCreationExpr, "", objectCreationExpr.getScope().isPresent() ? objectCreationExpr.getScope().get().toString() : "", instantiatedType, arguments, instantiatedType, calleeSignature, false, true, AccessSpecifier.NONE)); + callSites.add(createCallSite(objectCreationExpr, "", objectCreationExpr.getScope().isPresent() ? objectCreationExpr.getScope().get().toString() : "", instantiatedType, arguments, instantiatedType, calleeSignature, false, true, null, null, AccessSpecifier.NONE)); } return callSites; } +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") + private static Optional findCRUDQuery(String declaringType, String nameAsString, Optional> arguments) { + return CRUDFinderFactory.getCRUDFinders().map( + finder -> { + if (finder.isReadQuery(declaringType, nameAsString, arguments)) { + return CRUDQueryType.READ; + } + else if (finder.isWriteQuery(declaringType, nameAsString, arguments)) { + return CRUDQueryType.WRITE; + } + else if (finder.isNamedQuery(declaringType, nameAsString, arguments)) { + return CRUDQueryType.NAMED; + } + else + return null; + }) + .filter(Objects::nonNull) + .findFirst(); + } + + private static Optional findCRUDOperation(String declaringType, String nameAsString) { + return CRUDFinderFactory.getCRUDFinders().map( + finder -> { + if (finder.isCreateOperation(declaringType, nameAsString)) { + return CRUDOperationType.CREATE; + } + else if (finder.isReadOperation(declaringType, nameAsString)) { + return CRUDOperationType.READ; + } + else if (finder.isUpdateOperation(declaringType, nameAsString)) { + return CRUDOperationType.UPDATE; + } + else if (finder.isDeleteOperation(declaringType, nameAsString)) { + return CRUDOperationType.DELETE; + } + else + return null; + }) + .filter(Objects::nonNull) + .findFirst(); + } /** * Creates and returns a new CallSite object for the given expression, which @@ -719,7 +803,20 @@ private static List getCallSites(Optional callableBody) { * @param isConstructorCall * @return */ - private static CallSite createCallSite(Expression callExpr, String calleeName, String receiverExpr, String receiverType, List arguments, String returnType, String calleeSignature, boolean isStaticCall, boolean isConstructorCall, AccessSpecifier accessSpecifier) { + private static CallSite createCallSite( + Expression callExpr, + String calleeName, + String receiverExpr, + String receiverType, + List arguments, + String returnType, + String calleeSignature, + boolean isStaticCall, + boolean isConstructorCall, + CRUDOperation crudOperation, + CRUDQuery crudQuery, + AccessSpecifier accessSpecifier + ) { CallSite callSite = new CallSite(); callSite.setMethodName(calleeName); callSite.setReceiverExpr(receiverExpr); @@ -733,6 +830,8 @@ private static CallSite createCallSite(Expression callExpr, String calleeName, S callSite.setPublic(accessSpecifier.equals(AccessSpecifier.PUBLIC)); callSite.setProtected(accessSpecifier.equals(AccessSpecifier.PROTECTED)); callSite.setUnspecified(accessSpecifier.equals(AccessSpecifier.NONE)); + callSite.setCrudOperation(crudOperation); + callSite.setCrudQuery(crudQuery); if (callExpr.getRange().isPresent()) { callSite.setStartLine(callExpr.getRange().get().begin.line); callSite.setStartColumn(callExpr.getRange().get().begin.column); diff --git a/src/main/java/com/ibm/cldk/SystemDependencyGraph.java b/src/main/java/com/ibm/cldk/SystemDependencyGraph.java index 06fca3b9..0540fe99 100644 --- a/src/main/java/com/ibm/cldk/SystemDependencyGraph.java +++ b/src/main/java/com/ibm/cldk/SystemDependencyGraph.java @@ -241,7 +241,7 @@ public static List construct( Log.done("There were a total of " + cha.getNumberOfClasses() + " classes of which " + AnalysisUtils.getNumberOfApplicationClasses(cha) + " are application classes."); - // Initialize analysis options + // Initialize javaee options AnalysisOptions options = new AnalysisOptions(); Iterable entryPoints = AnalysisUtils.getEntryPoints(cha); options.setEntrypoints(entryPoints); diff --git a/src/main/java/com/ibm/cldk/entities/CRUDOperation.java b/src/main/java/com/ibm/cldk/entities/CRUDOperation.java index b230ceec..96d5bb7f 100644 --- a/src/main/java/com/ibm/cldk/entities/CRUDOperation.java +++ b/src/main/java/com/ibm/cldk/entities/CRUDOperation.java @@ -1,7 +1,7 @@ package com.ibm.cldk.entities; +import com.ibm.cldk.javaee.utils.enums.CRUDOperationType; import com.ibm.cldk.utils.annotations.NotImplemented; -import com.ibm.cldk.utils.annotations.Todo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; @@ -10,39 +10,16 @@ @Data @NoArgsConstructor @AllArgsConstructor -@NotImplemented public class CRUDOperation { - public enum OperationType { - CREATE, - READ, - UPDATE, - DELETE, - UNKNOWN - } + private int lineNumber = -1; + private CRUDOperationType operationType; - @Todo(comment = "Add more frameworks, and consider moving this outside because this may be generic.") @NotImplemented - public enum JavaFramework { - JPA, - SPRING - } - - private OperationType operationType; - private String targetTable; - private int lineNumber; - private int startPosition; - private int endPosition; - - @NotImplemented - private String operationString; + private String targetTable = null; @NotImplemented - private List involvedFields; + private List involvedColumns; @NotImplemented private String condition; @NotImplemented private List joinedTables; - @NotImplemented - private JavaFramework framework; - @NotImplemented - private boolean isBatchOperation = false; } \ No newline at end of file diff --git a/src/main/java/com/ibm/cldk/entities/CRUDQuery.java b/src/main/java/com/ibm/cldk/entities/CRUDQuery.java new file mode 100644 index 00000000..a498660c --- /dev/null +++ b/src/main/java/com/ibm/cldk/entities/CRUDQuery.java @@ -0,0 +1,17 @@ +package com.ibm.cldk.entities; + +import com.ibm.cldk.javaee.utils.enums.CRUDQueryType; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CRUDQuery { + private int lineNumber = -1; + private List queryArguments; + private CRUDQueryType queryType; +} diff --git a/src/main/java/com/ibm/cldk/entities/CallSite.java b/src/main/java/com/ibm/cldk/entities/CallSite.java index a0437884..6381dbbc 100644 --- a/src/main/java/com/ibm/cldk/entities/CallSite.java +++ b/src/main/java/com/ibm/cldk/entities/CallSite.java @@ -2,9 +2,12 @@ import lombok.Data; +import java.util.ArrayList; import java.util.List; +import java.util.Optional; @Data +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class CallSite { private String methodName; private String receiverExpr; @@ -19,7 +22,8 @@ public class CallSite { private boolean isUnspecified = false; private boolean isStaticCall; private boolean isConstructorCall; - private boolean isDatabase = false; + private CRUDOperation crudOperation = null; + private CRUDQuery crudQuery = null; private int startLine; private int startColumn; private int endLine; diff --git a/src/main/java/com/ibm/cldk/entities/Callable.java b/src/main/java/com/ibm/cldk/entities/Callable.java index f854acff..20ffe3af 100644 --- a/src/main/java/com/ibm/cldk/entities/Callable.java +++ b/src/main/java/com/ibm/cldk/entities/Callable.java @@ -25,7 +25,8 @@ public class Callable { private List accessedFields; private List callSites; private List variableDeclarations; + private List crudOperations = new ArrayList<>(); + private List crudQueries = new ArrayList<>(); private int cyclomaticComplexity; private boolean isEntrypoint = false; - private List crudOperations = null; } diff --git a/src/main/java/com/ibm/cldk/entities/Type.java b/src/main/java/com/ibm/cldk/entities/Type.java index 33c18688..c42d655f 100644 --- a/src/main/java/com/ibm/cldk/entities/Type.java +++ b/src/main/java/com/ibm/cldk/entities/Type.java @@ -2,6 +2,8 @@ import lombok.Data; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -15,15 +17,15 @@ public class Type { private boolean isInterface; private boolean isInnerClass; private boolean isLocalClass; - private List extendsList; + private List extendsList = new ArrayList<>(); private String comment; - private List implementsList; - private List modifiers; - private List annotations; + private List implementsList = new ArrayList<>(); + private List modifiers = new ArrayList<>(); + private List annotations = new ArrayList<>(); private String parentType; - private List nestedTypeDeclarations; - private Map callableDeclarations; - private List fieldDeclarations; - private List enumConstants; + private List nestedTypeDeclarations = new ArrayList<>(); + private Map callableDeclarations = new HashMap<>(); + private List fieldDeclarations = new ArrayList<>(); + private List enumConstants = new ArrayList<>(); private boolean isEntrypointClass = false; } \ No newline at end of file diff --git a/src/main/java/com/ibm/cldk/javaee/CRUDFinderFactory.java b/src/main/java/com/ibm/cldk/javaee/CRUDFinderFactory.java new file mode 100644 index 00000000..a1d6c052 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/CRUDFinderFactory.java @@ -0,0 +1,34 @@ +package com.ibm.cldk.javaee; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractCRUDFinder; +import com.ibm.cldk.javaee.jakarta.JPACRUDFinder; +import com.ibm.cldk.javaee.jdbc.JDBCCRUDFinder; +import com.ibm.cldk.javaee.spring.SpringCRUDFinder; +import org.apache.commons.lang3.NotImplementedException; + +import java.util.stream.Stream; + +public class CRUDFinderFactory { + public static AbstractCRUDFinder getCRUDFinder(String framework) { + switch (framework.toLowerCase()) { + case "jpa": + case "jakarta": + return new JPACRUDFinder(); + case "spring": + case "springboot": + return new SpringCRUDFinder(); + case "jdbc": + return new JDBCCRUDFinder(); + case "camel": + throw new NotImplementedException("Camel CRUD finder not implemented yet"); + case "struts": + throw new NotImplementedException("Struts CRUD finder not implemented yet"); + default: + throw new IllegalArgumentException("Unknown framework: " + framework); + } + } + + public static Stream getCRUDFinders() { + return Stream.of(new JPACRUDFinder(), new SpringCRUDFinder(), new JDBCCRUDFinder()); + } +} \ No newline at end of file diff --git a/src/main/java/com/ibm/cldk/javaee/EntrypointsFinderFactory.java b/src/main/java/com/ibm/cldk/javaee/EntrypointsFinderFactory.java new file mode 100644 index 00000000..5b081295 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/EntrypointsFinderFactory.java @@ -0,0 +1,33 @@ +package com.ibm.cldk.javaee; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractCRUDFinder; +import com.ibm.cldk.javaee.utils.interfaces.AbstractEntrypointFinder; +import com.ibm.cldk.javaee.jakarta.JPACRUDFinder; +import com.ibm.cldk.javaee.jakarta.JakartaEntrypointFinder; +import com.ibm.cldk.javaee.jdbc.JDBCCRUDFinder; +import com.ibm.cldk.javaee.spring.SpringCRUDFinder; +import com.ibm.cldk.javaee.struts.StrutsEntrypointFinder; +import org.apache.commons.lang3.NotImplementedException; + +import java.util.stream.Stream; + +public class EntrypointsFinderFactory { + public static AbstractEntrypointFinder getEntrypointFinder(String framework) { + switch (framework.toLowerCase()) { + case "jakarta": + return new JakartaEntrypointFinder(); + case "spring": + return new StrutsEntrypointFinder(); + case "camel": + throw new NotImplementedException("Camel CRUD finder not implemented yet"); + case "struts": + throw new NotImplementedException("Struts CRUD finder not implemented yet"); + default: + throw new IllegalArgumentException("Unknown framework: " + framework); + } + } + + public static Stream getEntrypointFinders() { + return Stream.of(new JPACRUDFinder(), new SpringCRUDFinder(), new JDBCCRUDFinder()); + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/camel/CamelEntrypointFinder.java b/src/main/java/com/ibm/cldk/javaee/camel/CamelEntrypointFinder.java new file mode 100644 index 00000000..4bd9f2e8 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/camel/CamelEntrypointFinder.java @@ -0,0 +1,17 @@ +package com.ibm.cldk.javaee.camel; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractEntrypointFinder; +import com.ibm.cldk.utils.annotations.NotImplemented; + +@NotImplemented(comment = "This class is not implemented yet. Leaving this here to refactor entrypoint detection.") +public class CamelEntrypointFinder extends AbstractEntrypointFinder { + @Override + public boolean isEntrypointClass(String receiverType, String name) { + return false; + } + + @Override + public boolean isEntrypointMethod(String receiverType, String name) { + return false; + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/jakarta/JPACRUDFinder.java b/src/main/java/com/ibm/cldk/javaee/jakarta/JPACRUDFinder.java new file mode 100644 index 00000000..a2d75aa6 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/jakarta/JPACRUDFinder.java @@ -0,0 +1,96 @@ +package com.ibm.cldk.javaee.jakarta; + +import com.ibm.cldk.javaee.utils.enums.CRUDOperationType; +import com.ibm.cldk.javaee.utils.enums.JPAQueryMethod; +import com.ibm.cldk.javaee.utils.interfaces.AbstractCRUDFinder; + +import java.util.List; +import java.util.Optional; + +public class JPACRUDFinder extends AbstractCRUDFinder { + + // Detect CREATE Operation + @Override + public boolean isCreateOperation(String receiverType, String name) { + return receiverType.endsWith("EntityManager") && name.equals("persist"); + } + + // Detect DELETE Operation + @Override + public boolean isDeleteOperation(String receiverType, String name) { + return receiverType.endsWith("EntityManager") && name.equals("remove"); + } + + // Detect UPDATE Operation, including query executions + @Override + public boolean isUpdateOperation(String receiverType, String name) { + if (receiverType.endsWith("Query")) { + Optional operation = JPAQueryMethod.getOperationForMethod(name); + // There's a caveat here because UPDATE/DELETE operations are both represented by the same method. + // See https://github.com/codellm-devkit/codeanalyzer-java/issues/100#issuecomment-2644492440 + return operation.isPresent() && (operation.get() == CRUDOperationType.UPDATE); + } + return receiverType.endsWith("EntityManager") && name.equals("merge"); + } + + // Detect READ Operation, including query executions using the JPAQueryMethod enum + @Override + public boolean isReadOperation(String receiverType, String name) { + if (receiverType.endsWith("EntityManager") && name.equals("find")) { + return true; + } + + if (receiverType.endsWith("Query")) { + Optional operation = JPAQueryMethod.getOperationForMethod(name); + return operation.isPresent() && operation.get() == CRUDOperationType.READ; + } + + return false; + } + + // Detect CRUD Query Creation (Only query definitions, not execution) + @Override + public boolean isCRUDQueryCreation(String declaringType, String methodName) { + return declaringType.endsWith("EntityManager") && + (methodName.equals("createQuery") || methodName.equals("createNamedQuery")); + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isReadQuery(String declaringType, String nameAsString, Optional> arguments) { + return isCRUDQueryCreation(declaringType, nameAsString) && arguments.stream().anyMatch(args -> { + String query = args.get(0).toLowerCase(); + return query.startsWith("select"); + }); + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isWriteQuery(String declaringType, String nameAsString, Optional> arguments) { + return isCRUDQueryCreation(declaringType, nameAsString) && arguments.stream().anyMatch(args -> { + String query = args.get(0).toLowerCase(); + return query.startsWith("update") || query.startsWith("delete") || query.startsWith("insert"); + }); + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isNamedQuery(String declaringType, String nameAsString, Optional> arguments) { + return declaringType.endsWith("EntityManager") && nameAsString.equals("createNamedQuery"); + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/jakarta/JakartaEntrypointFinder.java b/src/main/java/com/ibm/cldk/javaee/jakarta/JakartaEntrypointFinder.java new file mode 100644 index 00000000..083a7e44 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/jakarta/JakartaEntrypointFinder.java @@ -0,0 +1,17 @@ +package com.ibm.cldk.javaee.jakarta; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractEntrypointFinder; +import com.ibm.cldk.utils.annotations.NotImplemented; + +@NotImplemented(comment = "This class is not implemented yet. Leaving this here to refactor entrypoint detection.") +public class JakartaEntrypointFinder extends AbstractEntrypointFinder { + @Override + public boolean isEntrypointClass(String receiverType, String name) { + return false; + } + + @Override + public boolean isEntrypointMethod(String receiverType, String name) { + return false; + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/jdbc/JDBCCRUDFinder.java b/src/main/java/com/ibm/cldk/javaee/jdbc/JDBCCRUDFinder.java new file mode 100644 index 00000000..d90e0155 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/jdbc/JDBCCRUDFinder.java @@ -0,0 +1,99 @@ +package com.ibm.cldk.javaee.jdbc; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractCRUDFinder; + +import java.util.List; +import java.util.Optional; + +public class JDBCCRUDFinder extends AbstractCRUDFinder { + /** + * Detect if the method call is a create operation. + * + * @param receiverType + * @param name + * @return + */ + @Override + public boolean isCreateOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is a delete operation. + * + * @param receiverType + * @param name + * @return + */ + @Override + public boolean isDeleteOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is an update operation. + * + * @param receiverType + * @param name + * @return + */ + @Override + public boolean isUpdateOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is a read operation. + * + * @param receiverType + * @param name + * @return + */ + @Override + public boolean isReadOperation(String receiverType, String name) { + return false; + } + + /** + * @param declaringType + * @param methodName + * @return + */ + @Override + public boolean isCRUDQueryCreation(String declaringType, String methodName) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isReadQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isWriteQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isNamedQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/spring/SpringCRUDFinder.java b/src/main/java/com/ibm/cldk/javaee/spring/SpringCRUDFinder.java new file mode 100644 index 00000000..cdca5556 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/spring/SpringCRUDFinder.java @@ -0,0 +1,100 @@ +package com.ibm.cldk.javaee.spring; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractCRUDFinder; + +import java.util.List; +import java.util.Optional; + +public class SpringCRUDFinder extends AbstractCRUDFinder { + /** + * Detect if the method call is a create operation. + * + * @param receiverType The type of the receiver object. + * @param name The name of the method. + * @return True if the method call is a create operation, false otherwise. + */ + @Override + public boolean isCreateOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is a delete operation. + * + * @param receiverType The type of the receiver object. + * @param name The name of the method. + * @return True if the method call is a delete operation, false otherwise. + */ + @Override + public boolean isDeleteOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is an update operation. + * + * @param receiverType The type of the receiver object. + * @param name The name of the method. + * @return True if the method call is an update operation, false otherwise. + */ + @Override + public boolean isUpdateOperation(String receiverType, String name) { + return false; + } + + /** + * Detect if the method call is a read operation. + * + * @param receiverType The type of the receiver object. + * @param name The name of the method. + * @return True if the method call is a read operation, false otherwise. + */ + @Override + public boolean isReadOperation(String receiverType, String name) { + return false; + } + + /** + * @param declaringType + * @param methodName + * @return + */ + @Override + public boolean isCRUDQueryCreation(String declaringType, String methodName) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isReadQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isWriteQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } + + /** + * @param declaringType + * @param nameAsString + * @param arguments + * @return + */ + @Override + public boolean isNamedQuery(String declaringType, String nameAsString, Optional> arguments) { + return false; + } + +} diff --git a/src/main/java/com/ibm/cldk/javaee/spring/SpringEntrypointFinder.java b/src/main/java/com/ibm/cldk/javaee/spring/SpringEntrypointFinder.java new file mode 100644 index 00000000..f31063fd --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/spring/SpringEntrypointFinder.java @@ -0,0 +1,17 @@ +package com.ibm.cldk.javaee.spring; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractEntrypointFinder; +import com.ibm.cldk.utils.annotations.NotImplemented; + +@NotImplemented(comment = "This class is not implemented yet. Leaving this here to refactor entrypoint detection.") +public class SpringEntrypointFinder extends AbstractEntrypointFinder { + @Override + public boolean isEntrypointClass(String receiverType, String name) { + return false; + } + + @Override + public boolean isEntrypointMethod(String receiverType, String name) { + return false; + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/struts/StrutsEntrypointFinder.java b/src/main/java/com/ibm/cldk/javaee/struts/StrutsEntrypointFinder.java new file mode 100644 index 00000000..311d248f --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/struts/StrutsEntrypointFinder.java @@ -0,0 +1,15 @@ +package com.ibm.cldk.javaee.struts; + +import com.ibm.cldk.javaee.utils.interfaces.AbstractEntrypointFinder; + +public class StrutsEntrypointFinder extends AbstractEntrypointFinder { + @Override + public boolean isEntrypointClass(String receiverType, String name) { + return false; + } + + @Override + public boolean isEntrypointMethod(String receiverType, String name) { + return false; + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDOperationType.java b/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDOperationType.java new file mode 100644 index 00000000..13a7dedf --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDOperationType.java @@ -0,0 +1,8 @@ +package com.ibm.cldk.javaee.utils.enums; + +public enum CRUDOperationType { + CREATE, + READ, + UPDATE, + DELETE; +} \ No newline at end of file diff --git a/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDQueryType.java b/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDQueryType.java new file mode 100644 index 00000000..8f95f0f9 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/utils/enums/CRUDQueryType.java @@ -0,0 +1,7 @@ +package com.ibm.cldk.javaee.utils.enums; + +public enum CRUDQueryType { + READ, + WRITE, + NAMED; +} diff --git a/src/main/java/com/ibm/cldk/javaee/utils/enums/JPAQueryMethod.java b/src/main/java/com/ibm/cldk/javaee/utils/enums/JPAQueryMethod.java new file mode 100644 index 00000000..e391821e --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/utils/enums/JPAQueryMethod.java @@ -0,0 +1,45 @@ +package com.ibm.cldk.javaee.utils.enums; + +import com.ibm.cldk.utils.annotations.Note; +import lombok.Getter; + +import java.util.Optional; + +@Getter +public enum JPAQueryMethod { + // Read Operations + GET_RESULT_LIST(CRUDOperationType.READ), + GET_SINGLE_RESULT(CRUDOperationType.READ), + GET_FIRST_RESULT(CRUDOperationType.READ), + GET_MAX_RESULTS(CRUDOperationType.READ), + + // Write Operations + @Note("There is a possiblity that the user may execute a delete action using the executeUpdate method. There is no way to differentiate between an update and delete operation without doing a dataflow analysis on the query string because the query string may be defined anywhere in the code. So for now, we are assuming that executeUpdate is an update operation.") + EXECUTE_UPDATE(CRUDOperationType.UPDATE), + + // Non-CRUD Methods (configuration or metadata) + GET_FLUSH_MODE(null), + GET_HINTS(null), + GET_LOCK_MODE(null), + GET_PARAMETER(null), + GET_PARAMETERS(null), + GET_PARAMETER_VALUE(null), + IS_BOUND(null), + UNWRAP(null); + + private final CRUDOperationType crudOperation; + + JPAQueryMethod(CRUDOperationType crudOperation) { + this.crudOperation = crudOperation; + } + + public static Optional getOperationForMethod(String methodName) { + try { + // A small hack to convert camelCase to snake_case and also to uppercase. Basically, we want getSingleResult to get converted to GET_SINGLE_RESULT so as to + // match the enum values conventions. + return Optional.ofNullable(JPAQueryMethod.valueOf(methodName.replaceAll("([a-z])([A-Z]+)", "$1_$2").toUpperCase()).getCrudOperation()); + } catch (IllegalArgumentException e) { + return Optional.empty(); + } + } +} diff --git a/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractCRUDFinder.java b/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractCRUDFinder.java new file mode 100644 index 00000000..02a331f4 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractCRUDFinder.java @@ -0,0 +1,27 @@ +package com.ibm.cldk.javaee.utils.interfaces; + +import java.util.List; +import java.util.Optional; + +/** + * Abstract base class for finding CRUD operations in various frameworks. + */ +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") +public abstract class AbstractCRUDFinder { + public abstract boolean isCreateOperation(String receiverType, String methodName); + + public abstract boolean isDeleteOperation(String receiverType, String methodName); + + public abstract boolean isUpdateOperation(String receiverType, String methodName); + + public abstract boolean isReadOperation(String receiverType, String methodName); + + // Detect CRUD Query Creation (Only query definitions, not execution) + public abstract boolean isCRUDQueryCreation(String declaringType, String methodName); + + public abstract boolean isReadQuery(String declaringType, String nameAsString, Optional> arguments); + + public abstract boolean isWriteQuery(String declaringType, String nameAsString, Optional> arguments); + + public abstract boolean isNamedQuery(String declaringType, String nameAsString, Optional> arguments); +} diff --git a/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractEntrypointFinder.java b/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractEntrypointFinder.java new file mode 100644 index 00000000..e3b8f326 --- /dev/null +++ b/src/main/java/com/ibm/cldk/javaee/utils/interfaces/AbstractEntrypointFinder.java @@ -0,0 +1,23 @@ +package com.ibm.cldk.javaee.utils.interfaces; + +import com.ibm.cldk.utils.annotations.NotImplemented; + +@NotImplemented(comment = "This class is not implemented yet. Leaving this here to refactor entrypoint detection.") +public abstract class AbstractEntrypointFinder { + /** + * Enum for rules. + */ + enum Rulest{ + } + + /** + * Detect if the method is an entrypoint. + * + * @param receiverType The type of the receiver object. + * @param name The name of the method. + * @return True if the method is an entrypoint, false otherwise. + */ + public abstract boolean isEntrypointClass(String receiverType, String name); + + public abstract boolean isEntrypointMethod(String receiverType, String name); +} diff --git a/src/main/java/com/ibm/cldk/utils/BuildProject.java b/src/main/java/com/ibm/cldk/utils/BuildProject.java index 61ca639e..910194d4 100644 --- a/src/main/java/com/ibm/cldk/utils/BuildProject.java +++ b/src/main/java/com/ibm/cldk/utils/BuildProject.java @@ -34,7 +34,7 @@ public class BuildProject { public static String getMavenCommand() { String mvnSystemCommand = Arrays.stream(System.getenv("PATH").split(System.getProperty("path.separator"))).map(path -> new File(path, System.getProperty("os.name").toLowerCase().contains("windows") ? "mvn.cmd" : "mvn")).filter(File::exists).findFirst().map(File::getAbsolutePath).orElse(null); File mvnWrapper = System.getProperty("os.name").toLowerCase().contains("windows") ? new File(projectRootPom, "mvnw.cmd") : new File(projectRootPom, "mvnw"); - return commandExists(mvnWrapper).getKey() ? mvnWrapper.toString() : mvnSystemCommand; + return commandExists(mvnWrapper.getAbsoluteFile()).getKey() ? mvnWrapper.getAbsoluteFile().toString() : mvnSystemCommand; } /** @@ -46,7 +46,7 @@ public static String getGradleCommand() { String gradleSystemCommand = Arrays.stream(System.getenv("PATH").split(System.getProperty("path.separator"))).map(path -> new File(path, System.getProperty("os.name").toLowerCase().contains("windows") ? "gradle.bat" : "gradle")).filter(File::exists).findFirst().map(File::getAbsolutePath).orElse(null); File gradleWrapper = System.getProperty("os.name").toLowerCase().contains("windows") ? new File(projectRootPom, "gradlew.bat") : new File(projectRootPom, "gradlew"); - return commandExists(gradleWrapper).getKey() ? gradleWrapper.toString() : gradleSystemCommand; + return commandExists(gradleWrapper.getAbsoluteFile()).getKey() ? gradleWrapper.getAbsoluteFile() .toString() : gradleSystemCommand; } public static Path tempInitScript; @@ -204,7 +204,7 @@ private static boolean mkLibDepDirs(String projectPath) { * Downloads library dependency jars of the given project so that the jars can be used * for type resolution during symbol table creation. * - * @param projectPath Path to the project under analysis + * @param projectPath Path to the project under javaee * @return true if dependency download succeeds; false otherwise */ public static boolean downloadLibraryDependencies(String projectPath, String projectRootPom) throws IOException { diff --git a/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java b/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java index d6178a15..f57031a3 100644 --- a/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java +++ b/src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java @@ -14,10 +14,13 @@ public static List classFilesStream(String projectPath) throws IOException Log.info("Finding *.class files in " + projectDir); if (Files.exists(projectDir)) { try (Stream paths = Files.walk(projectDir)) { - return paths - .filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class")) - .filter(file -> !file.toAbsolutePath().toString().contains("test/resources/")) - .filter(file -> !file.toAbsolutePath().toString().contains("main/resources/")) + return paths.filter(file -> !Files.isDirectory(file) && file.toString().endsWith(".class")) + .filter(file -> { + // Let's find the path relative to the project directory + Path relativePath = projectDir.relativize(file.toAbsolutePath()); + String relativePathAsString = relativePath.toString().replace("\\", "/"); // Windows fix + return !relativePathAsString.contains("test/resources/") && !relativePathAsString.contains("main/resources/"); + }) .collect(Collectors.toList()); } } diff --git a/src/main/java/com/ibm/cldk/utils/ScopeUtils.java b/src/main/java/com/ibm/cldk/utils/ScopeUtils.java index fe233e9a..b6f6c1e4 100644 --- a/src/main/java/com/ibm/cldk/utils/ScopeUtils.java +++ b/src/main/java/com/ibm/cldk/utils/ScopeUtils.java @@ -43,23 +43,23 @@ public class ScopeUtils { public static String[] stdLibs; /** - * Create an analysis scope base on the input + * Create an javaee scope base on the input * * @param projectPath The root directory of the project to be analyzed. - * @return scope The created analysis scope + * @return scope The created javaee scope * @throws IOException the io exception */ /** - * Create an analysis scope base on the input + * Create an javaee scope base on the input * * @param projectPath The root directory of the project to be analyzed. * @param applicationDeps the application deps - * @return scope The created analysis scope + * @return scope The created javaee scope * @throws IOException the io exception */ public static AnalysisScope createScope(String projectPath, String applicationDeps, String build) throws IOException { - Log.info("Create analysis scope."); + Log.info("Create javaee scope."); AnalysisScope scope = new JavaSourceAnalysisScope(); addDefaultExclusions(scope); @@ -88,7 +88,7 @@ public static AnalysisScope createScope(String projectPath, String applicationDe Objects.requireNonNull(jarFilesStream(applicationDeps)).stream() .forEach( extraLibJar -> { - Log.info("-> Adding dependency " + extraLibJar + " to analysis scope."); + Log.info("-> Adding dependency " + extraLibJar + " to javaee scope."); try { scope.addToScope(ClassLoaderReference.Extension, new JarFile(extraLibJar.toAbsolutePath().toFile())); } catch (IOException e) { diff --git a/src/main/java/com/ibm/cldk/utils/annotations/NotImplemented.java b/src/main/java/com/ibm/cldk/utils/annotations/NotImplemented.java index 9e658bcc..f6900e18 100644 --- a/src/main/java/com/ibm/cldk/utils/annotations/NotImplemented.java +++ b/src/main/java/com/ibm/cldk/utils/annotations/NotImplemented.java @@ -7,7 +7,5 @@ @Retention(RetentionPolicy.RUNTIME) public @interface NotImplemented { String value() default ""; - String since() default ""; - String issue() default ""; String comment() default ""; } \ No newline at end of file diff --git a/src/main/java/com/ibm/cldk/utils/annotations/Note.java b/src/main/java/com/ibm/cldk/utils/annotations/Note.java new file mode 100644 index 00000000..cf12e6fa --- /dev/null +++ b/src/main/java/com/ibm/cldk/utils/annotations/Note.java @@ -0,0 +1,10 @@ +package com.ibm.cldk.utils.annotations; + +import java.lang.annotation.*; + +@Documented +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE, ElementType.MODULE, ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Note { + String value() default ""; +} diff --git a/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java b/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java index 0697d936..ca8824f6 100644 --- a/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java +++ b/src/test/java/com/ibm/cldk/CodeAnalyzerIntegrationTest.java @@ -1,8 +1,5 @@ package com.ibm.cldk; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Assertions; @@ -15,15 +12,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.nio.file.Path; import java.nio.file.Paths; -import java.text.MessageFormat; -import java.util.Map; import java.util.Properties; -import static com.ibm.cldk.CodeAnalyzer.gson; -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; @Testcontainers @SuppressWarnings("resource") @@ -59,6 +50,7 @@ public class CodeAnalyzerIntegrationTest { BindMode.READ_WRITE) .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("build/libs")), "/opt/jars") .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-corrupt-test")), "/test-applications/mvnw-corrupt-test") + .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/plantsbywebsphere")), "/test-applications/plantsbywebsphere") .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test"); @Container @@ -70,7 +62,6 @@ public class CodeAnalyzerIntegrationTest { .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/mvnw-working-test")), "/test-applications/mvnw-working-test") .withCopyFileToContainer(MountableFile.forHostPath(Paths.get(System.getProperty("user.dir")).resolve("src/test/resources/test-applications/daytrader8")), "/test-applications/daytrader8"); - @BeforeAll static void setUp() { Properties properties = new Properties(); @@ -140,7 +131,7 @@ void corruptMavenShouldProduceAnalysisArtifactsWhenMVNCommandIsInPath() throws I @Test void corruptMavenShouldNotTerminateWithErrorWhenMavenIsNotPresentUnlessAnalysisLevel2() throws IOException, InterruptedException { - // When analysis level 2, we should get a Runtime Exception + // When javaee level 2, we should get a Runtime Exception var runCodeAnalyzer = container.execInContainer( "java", "-jar", @@ -165,4 +156,49 @@ void shouldBeAbleToGenerateAnalysisArtifactForDaytrader8() throws Exception { Assertions.assertTrue(runCodeAnalyzerOnDaytrader8.getStdout().contains("\"is_entrypoint_class\": true"), "No entry point classes found"); Assertions.assertTrue(runCodeAnalyzerOnDaytrader8.getStdout().contains("\"is_entrypoint\": true"), "No entry point methods found"); } + + @Test + void shouldBeAbleToDetectCRUDOperationsAndQueriesForPlantByWebsphere() throws Exception { + var runCodeAnalyzerOnPlantsByWebsphere = container.execInContainer( + "java", + "-jar", + String.format("/opt/jars/codeanalyzer-%s.jar", codeanalyzerVersion), + "--input=/test-applications/plantsbywebsphere", + "--analysis-level=1", "--verbose" + ); + + String output = runCodeAnalyzerOnPlantsByWebsphere.getStdout(); + + Assertions.assertTrue(output.contains("\"query_type\": \"NAMED\""), "No entry point classes found"); + Assertions.assertTrue(output.contains("\"operation_type\": \"READ\""), "No entry point methods found"); + Assertions.assertTrue(output.contains("\"operation_type\": \"UPDATE\""), "No entry point methods found"); + Assertions.assertTrue(output.contains("\"operation_type\": \"CREATE\""), "No entry point methods found"); + + // Convert the expected JSON structure into a string + String expectedCrudOperation = + "\"crud_operations\": [" + + "{" + + "\"line_number\": 115," + + "\"operation_type\": \"READ\"," + + "\"target_table\": null," + + "\"involved_columns\": null," + + "\"condition\": null," + + "\"joined_tables\": null" + + "}]"; + + // Expected JSON for CRUD Queries + String expectedCrudQuery = + "\"crud_queries\": [" + + "{" + + "\"line_number\": 141,"; + + // Normalize the output and expected strings to ignore formatting differences + String normalizedOutput = output.replaceAll("\\s+", ""); + String normalizedExpectedCrudOperation = expectedCrudOperation.replaceAll("\\s+", ""); + String normalizedExpectedCrudQuery = expectedCrudQuery.replaceAll("\\s+", ""); + + // Assertions for both CRUD operations and queries + Assertions.assertTrue(normalizedOutput.contains(normalizedExpectedCrudOperation), "Expected CRUD operation JSON structure not found"); + Assertions.assertTrue(normalizedOutput.contains(normalizedExpectedCrudQuery), "Expected CRUD query JSON structure not found"); + } } \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/.gitignore b/src/test/resources/test-applications/plantsbywebsphere/.gitignore new file mode 100644 index 00000000..33f0b551 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/.gitignore @@ -0,0 +1,49 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +.metadata +.recommenders +RemoteSystemsTempFiles + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.rar +*.tar +*.zip +*.war + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +/.apt_generated/ +/target/ +.settings/ +/.gradle/ +/build/ +bin/ +.classpath +.project diff --git a/src/test/resources/test-applications/plantsbywebsphere/LICENSE b/src/test/resources/test-applications/plantsbywebsphere/LICENSE new file mode 100644 index 00000000..8dada3ed --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/test/resources/test-applications/plantsbywebsphere/README.md b/src/test/resources/test-applications/plantsbywebsphere/README.md new file mode 100644 index 00000000..b8d9fde0 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/README.md @@ -0,0 +1,40 @@ +# sample.plantsbywebsphere +Updated Plants By WebSphere showcase sample to run on WebSphere Liberty. + +This Repository is for testing the PlantsByWebSphere application +in an open source development environment. + +## How to run: + +1. Clone the github repo +2. Start the Liberty server and open the application in a web browser by running: +``` +./gradlew start open +``` + +### Collaborators: +- Dalia A. Abo Sheasha +- Ryan Gallus +- Samuel Ivanecky +- Alex Mortimer + +### Overview +This repository contains the PlantsByWebSphere Java EE sample application. There are two versions of the sample application. The main branch contains the original version of PlantsByWebSphere, while the rest branch contains an updated version which is still under development. + +### Original +The original version of PlantsByWebSphere is a simple Java EE application which uses CDI managed beans, Java Server Faces (JSF), and Java Server Pages (JSP). The sample runs on both TWAS and Liberty. + +### Updated +The updated version of PlantsByWebSphere replaces components of the original with a more modern web application design. JSF and JSP have been replaced by JAX-RS with the application redesigned as a RESTful Web Service. The client is a simple bootstrap framework, and all client JavaScript can be found in application.js. The server's additional REST code can be found in ApplicationResource.java. + +Additionally, this new version supports the use of the javaMail-1.5 feature which requires the configuration of a mailSession object in the server.xml. Below is an example mailSession configuration. Make sure to modify the the mail account (Gmail, Yahoo, etc.) settings and allow access of less secure applications in order for it to connect with PlantsByWebSphere. + +```xml + + + + + + + +``` diff --git a/src/test/resources/test-applications/plantsbywebsphere/build.gradle b/src/test/resources/test-applications/plantsbywebsphere/build.gradle new file mode 100644 index 00000000..4e5b57ab --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/build.gradle @@ -0,0 +1,82 @@ +plugins { + id 'war' + id 'io.openliberty.tools.gradle.Liberty' version '3.9.2' +} + +group = 'net.wasdev.sample' +version = '1.0-SNAPSHOT' +description = "PlantsByWebSphere" + +sourceCompatibility = 1.7 +targetCompatibility = 1.7 +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +repositories { + mavenCentral() +} + +configurations { + serverLibs +} + +dependencies { + providedCompile 'javax:javaee-api:7.0' + serverLibs 'org.apache.derby:derby:10.11.1.1' + libertyRuntime 'io.openliberty:openliberty-runtime:23.0.0.12' +} + +task copyServerLibs(type: Copy) { + shouldRunAfter 'libertyCreate' + from configurations.serverLibs + into "${buildDir}/wlp/usr/servers/${rootProject.name}Server/lib" +} + +war.archiveName = "${rootProject.name}.war" +test.dependsOn 'war' + +test { + defaultCharacterEncoding = "UTF-8" + useJUnitPlatform() + testLogging { + displayGranularity = 1 + showStandardStreams = true + showStackTraces = true + exceptionFormat = 'full' + events 'PASSED', 'FAILED', 'SKIPPED' + } +} + +ext { + appUrl = "http://localhost:9080/${rootProject.name}/" +} + +liberty { + server { + name = rootProject.name + 'Server' + deploy { + apps = [war] // Correct syntax for deploying apps + } + looseApplication = false + configDirectory = file('src/main/liberty/config') + } +} + +task openBrowser { + description = "Open browser to ${appUrl}" + doLast { + java.awt.Desktop.desktop.browse "${appUrl}".toURI() + } +} + +clean.dependsOn 'libertyStop' +libertyPackage.dependsOn 'libertyStop', 'copyServerLibs' +libertyStart.dependsOn 'libertyStop', 'copyServerLibs' +libertyRun.dependsOn 'libertyStop' +libertyStart.doLast { + println "Application available at: ${appUrl}" +} + +task start { dependsOn 'libertyStart' } +task stop { dependsOn 'libertyStop' } \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/gradle/wrapper/gradle-wrapper.properties b/src/test/resources/test-applications/plantsbywebsphere/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..070cb702 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/test/resources/test-applications/plantsbywebsphere/gradlew b/src/test/resources/test-applications/plantsbywebsphere/gradlew new file mode 100755 index 00000000..af6708ff --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# 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='"-Xmx64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +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 + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +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" "$@" diff --git a/src/test/resources/test-applications/plantsbywebsphere/gradlew.bat b/src/test/resources/test-applications/plantsbywebsphere/gradlew.bat new file mode 100755 index 00000000..0f8d5937 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +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="-Xmx64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/test/resources/test-applications/plantsbywebsphere/settings.gradle b/src/test/resources/test-applications/plantsbywebsphere/settings.gradle new file mode 100644 index 00000000..46652e4c --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'PlantsByWebSphere' diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/BackOrderMgr.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/BackOrderMgr.java new file mode 100755 index 00000000..e44781c5 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/BackOrderMgr.java @@ -0,0 +1,238 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; +import java.util.Collection; + +import javax.annotation.security.RolesAllowed; +import javax.enterprise.context.Dependent; +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import com.ibm.websphere.samples.pbw.jpa.BackOrder; +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * The BackOrderMgr provides a transactional and secured facade to access back order information. + * This bean no longer requires an interface as there is one and only one implementation. + */ +@Dependent +@RolesAllowed("SampAdmin") +public class BackOrderMgr implements Serializable { + @PersistenceContext(unitName = "PBW") + private EntityManager em; + + /** + * Method createBackOrder. + * + * @param inventoryID + * @param amountToOrder + * @param maximumItems + */ + public void createBackOrder(String inventoryID, int amountToOrder, int maximumItems) { + try { + Util.debug("BackOrderMgr.createBackOrder() - Entered"); + BackOrder backOrder = null; + try { + // See if there is already an existing backorder and increase + // the order quantity + // but only if it has not been sent to the supplier. + Query q = em.createNamedQuery("findByInventoryID"); + q.setParameter("id", inventoryID); + backOrder = (BackOrder) q.getSingleResult(); + if (!(backOrder.getStatus().equals(Util.STATUS_ORDERSTOCK))) { + Util.debug("BackOrderMgr.createBackOrder() - Backorders found but have already been ordered from the supplier"); + // throw new FinderException(); + } + // Increase the BackOrder quantity for an existing Back Order. + backOrder.setQuantity(backOrder.getQuantity() + amountToOrder); + } catch (NoResultException e) { + Util.debug("BackOrderMgr.createBackOrder() - BackOrder doesn't exist." + e); + Util.debug("BackOrderMgr.createBackOrder() - Creating BackOrder for InventoryID: " + inventoryID); + // Order enough stock from the supplier to reach the maximum + // threshold and to + // satisfy the back order. + amountToOrder = maximumItems + amountToOrder; + Inventory inv = em.find(Inventory.class, inventoryID); + BackOrder b = new BackOrder(inv, amountToOrder); + em.persist(b); + } + } catch (Exception e) { + Util.debug("BackOrderMgr.createBackOrder() - Exception: " + e); + } + } + + /** + * Method findBackOrderItems. + * + * @return Collection + */ + @SuppressWarnings("unchecked") + public Collection findBackOrders() { + Query q = em.createNamedQuery("findAllBackOrders"); + return q.getResultList(); + } + + /** + * Method deleteBackOrder. + * + * @param backOrderID + */ + public void deleteBackOrder(String backOrderID) { + Util.debug("BackOrderMgr.deleteBackOrder() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKeyUpdate(backOrderID); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + em.remove(backOrder); + } + + /** + * Method receiveConfirmation. + * + * @param backOrderID + * / public int receiveConfirmation(String backOrderID) { int rc = 0; BackOrder + * backOrder; Util.debug( + * "BackOrderMgr.receiveConfirmation() - Finding Back Order for backOrderID=" + + * backOrderID); backOrder = em.find(BackOrder.class, backOrderID); + * backOrder.setStatus(Util.STATUS_RECEIVEDSTOCK); Util.debug( + * "BackOrderMgr.receiveConfirmation() - Updating status(" + + * Util.STATUS_RECEIVEDSTOCK + ") of backOrderID(" + backOrderID + ")"); return (rc); + * } + */ + + /** + * Method orderStock. + * + * @param backOrderID + * @param quantity + * / public void orderStock(String backOrderID, int quantity) { + * this.setBackOrderStatus(backOrderID, Util.STATUS_ORDEREDSTOCK); + * this.setBackOrderQuantity(backOrderID, quantity); + * this.setBackOrderOrderDate(backOrderID); } + */ + + /** + * Method updateStock. + * + * @param backOrderID + * @param quantity + */ + public void updateStock(String backOrderID, int quantity) { + this.setBackOrderStatus(backOrderID, Util.STATUS_ADDEDSTOCK); + } + + /** + * @param backOrderID + * / public void abortorderStock(String backOrderID) { Util.debug( + * "backOrderStockBean.abortorderStock() - Aborting orderStock transation for backorderID: " + * + backOrderID); // Reset the back order status since the order failed. + * this.setBackOrderStatus(backOrderID, Util.STATUS_ORDERSTOCK); } + */ + + /** + * Method getBackOrderID. + * + * @param backOrderID + * @return String / public String getBackOrderID(String backOrderID) { String retbackOrderID = + * ""; Util.debug( "BackOrderMgr.getBackOrderID() - Entered"); // BackOrderLocal + * backOrder = getBackOrderLocalHome().findByPrimaryKey(new BackOrderKey(backOrderID)); + * BackOrder backOrder = em.find(BackOrder.class, backOrderID); retbackOrderID = + * backOrder.getBackOrderID(); return retbackOrderID; } + */ + + /** + * Method getBackOrderInventoryID. + * + * @param backOrderID + * @return String + */ + public String getBackOrderInventoryID(String backOrderID) { + String retinventoryID = ""; + + Util.debug("BackOrderMgr.getBackOrderID() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKey(new + // BackOrderKey(backOrderID)); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + retinventoryID = backOrder.getInventory().getInventoryId(); + + return retinventoryID; + } + + /** + * Method getBackOrderQuantity. + * + * @param backOrderID + * @return int + */ + public int getBackOrderQuantity(String backOrderID) { + int backOrderQuantity = -1; + Util.debug("BackOrderMgr.getBackOrderQuantity() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKey(new + // BackOrderKey(backOrderID)); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + backOrderQuantity = backOrder.getQuantity(); + return backOrderQuantity; + } + + /** + * Method setBackOrderQuantity. + * + * @param backOrderID + * @param quantity + */ + public void setBackOrderQuantity(String backOrderID, int quantity) { + Util.debug("BackOrderMgr.setBackOrderQuantity() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKeyUpdate(backOrderID); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + backOrder.setQuantity(quantity); + } + + /** + * Method setBackOrderStatus. + * + * @param backOrderID + * @param Status + */ + public void setBackOrderStatus(String backOrderID, String Status) { + Util.debug("BackOrderMgr.setBackOrderStatus() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKeyUpdate(backOrderID); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + backOrder.setStatus(Status); + } + + /** + * Method setBackOrderOrderDate. + * + * @param backOrderID + */ + public void setBackOrderOrderDate(String backOrderID) { + Util.debug("BackOrderMgr.setBackOrderQuantity() - Entered"); + // BackOrderLocal backOrder = + // getBackOrderLocalHome().findByPrimaryKeyUpdate(backOrderID); + BackOrder backOrder = em.find(BackOrder.class, backOrderID); + backOrder.setOrderDate(System.currentTimeMillis()); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CatalogMgr.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CatalogMgr.java new file mode 100755 index 00000000..94da49ac --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CatalogMgr.java @@ -0,0 +1,205 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; +import java.util.Vector; + +import javax.enterprise.context.Dependent; +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * The CatalogMgr provides transactional access to the catalog of items the store is willing to sell + * to customers. + * + * @see com.ibm.websphere.samples.pbw.jpa.Inventory + */ +@Dependent +@SuppressWarnings("unchecked") +public class CatalogMgr implements Serializable { + @PersistenceContext(unitName = "PBW") + EntityManager em; + + /** + * Get all inventory items. + * + * @return Vector of Inventorys. / public Vector getItems() { Vector items + * = new Vector(); int count = Util.getCategoryStrings().length; for (int i = + * 0; i < count; i++) { items.addAll(getItemsByCategory(i)); } return items; } + */ + + /** + * Get all inventory items for the given category. + * + * @param category + * of items desired. + * @return Vector of Inventory. + */ + public Vector getItemsByCategory(int category) { + Query q = em.createNamedQuery("getItemsByCategory"); + q.setParameter("category", category); + // The return type must be Vector because the PBW client ActiveX sample requires Vector + return new Vector(q.getResultList()); + } + + /** + * Get inventory items that contain a given String within their names. + * + * @param name + * String to search names for. + * @return A Vector of Inventorys that match. / public Vector getItemsLikeName(String + * name) { Query q = em.createNamedQuery("getItemsLikeName"); q.setParameter("name", '%' + * + name + '%'); //The return type must be Vector because the PBW client ActiveX sample + * requires Vector return new Vector(q.getResultList()); } + */ + + /** + * Get the StoreItem for the given ID. + * + * @param inventoryID + * - ID of the Inventory item desired. + * @return StoreItem / public StoreItem getItem(String inventoryID) { return new + * StoreItem(getItemInventory(inventoryID)); } + */ + + /** + * Get the Inventory item for the given ID. + * + * @param inventoryID + * - ID of the Inventory item desired. + * @return Inventory + */ + public Inventory getItemInventory(String inventoryID) { + Inventory si = null; + Util.debug("getItemInventory id=" + inventoryID); + si = em.find(Inventory.class, inventoryID); + return si; + } + + /** + * Add an inventory item. + * + * @param item + * The Inventory to add. + * @return True, if item added. + */ + public boolean addItem(Inventory item) { + boolean retval = true; + Util.debug("addItem " + item.getInventoryId()); + em.persist(item); + em.flush(); + return retval; + } + + /** + * Add an StoreItem item (same as Inventory item). + * + * @param item + * The StoreItem to add. + * @return True, if item added. / public boolean addItem(StoreItem item) { return addItem(new + * Inventory(item)); } + */ + + /** + * Delete an inventory item. + * + * @param inventoryID + * The ID of the inventory item to delete. + * @return True, if item deleted. / public boolean deleteItem(String inventoryID) { boolean + * retval = true; em.remove(em.find(Inventory.class, inventoryID)); return retval; } + */ + + /** + * Get the image for the inventory item. + * + * @param inventoryID + * The id of the inventory item wanted. + * @return Buffer containing the image. + */ + public byte[] getItemImageBytes(String inventoryID) { + byte[] retval = null; + Inventory inv = getInv(inventoryID); + if (inv != null) { + retval = inv.getImgbytes(); + } + + return retval; + } + + /** + * Set the image for the inventory item. + * + * @param inventoryID + * The id of the inventory item wanted. + * @param imgbytes + * Buffer containing the image. + */ + public void setItemImageBytes(String inventoryID, byte[] imgbytes) { + Inventory inv = getInvUpdate(inventoryID); + if (inv != null) { + inv.setImgbytes(imgbytes); + } + } + + /** + * Set the inventory item's quantity. + * + * @param inventoryID + * The inventory item's ID. + * @param quantity + * The inventory item's new quantity. + */ + public void setItemQuantity(String inventoryID, int quantity) { + Inventory inv = getInvUpdate(inventoryID); + if (inv != null) { + inv.setQuantity(quantity); + } + } + + /** + * Get a remote Inventory object. + * + * @param inventoryID + * The id of the inventory item wanted. + * @return Reference to the remote Inventory object. + */ + private Inventory getInv(String inventoryID) { + return em.find(Inventory.class, inventoryID); + } + + /** + * Get a remote Inventory object to Update. + * + * @param inventoryID + * The id of the inventory item wanted. + * @return Reference to the remote Inventory object. + */ + private Inventory getInvUpdate(String inventoryID) { + Inventory inv = null; + inv = em.find(Inventory.class, inventoryID); + em.lock(inv, LockModeType.OPTIMISTIC_FORCE_INCREMENT); + em.refresh(inv); + return inv; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CustomerMgr.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CustomerMgr.java new file mode 100755 index 00000000..b5a53d04 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/CustomerMgr.java @@ -0,0 +1,176 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; + +import javax.enterprise.context.Dependent; +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; +import javax.persistence.PersistenceContext; +import javax.transaction.Transactional; + +import com.ibm.websphere.samples.pbw.jpa.Customer; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * The CustomerMgr provides a transactional facade for access to a user DB as well as simple + * authentication support for those users. + * + */ +@Transactional +@Dependent +public class CustomerMgr implements Serializable { + @PersistenceContext(unitName = "PBW") + EntityManager em; + + /** + * Create a new user. + * + * @param customerID + * The new customer ID. + * @param password + * The password for the customer ID. + * @param firstName + * First name. + * @param lastName + * Last name. + * @param addr1 + * Address line 1. + * @param addr2 + * Address line 2. + * @param addrCity + * City address information. + * @param addrState + * State address information. + * @param addrZip + * Zip code address information. + * @param phone + * User's phone number. + * @return Customer + */ + public Customer createCustomer(String customerID, + String password, + String firstName, + String lastName, + String addr1, + String addr2, + String addrCity, + String addrState, + String addrZip, + String phone) { + Customer c = new Customer(customerID, password, firstName, lastName, addr1, addr2, addrCity, addrState, addrZip, + phone); + em.persist(c); + em.flush(); + return c; + } + + /** + * Retrieve an existing user. + * + * @param customerID + * The customer ID. + * @return Customer + */ + public Customer getCustomer(String customerID) { + Customer c = em.find(Customer.class, customerID); + return c; + + } + + /** + * Update an existing user. + * + * @param customerID + * The customer ID. + * @param firstName + * First name. + * @param lastName + * Last name. + * @param addr1 + * Address line 1. + * @param addr2 + * Address line 2. + * @param addrCity + * City address information. + * @param addrState + * State address information. + * @param addrZip + * Zip code address information. + * @param phone + * User's phone number. + * @return Customer + */ + public Customer updateUser(String customerID, + String firstName, + String lastName, + String addr1, + String addr2, + String addrCity, + String addrState, + String addrZip, + String phone) { + Customer c = em.find(Customer.class, customerID); + em.lock(c, LockModeType.WRITE); + em.refresh(c); + + c.setFirstName(firstName); + c.setLastName(lastName); + c.setAddr1(addr1); + c.setAddr2(addr2); + c.setAddrCity(addrCity); + c.setAddrState(addrState); + c.setAddrZip(addrZip); + c.setPhone(phone); + + return c; + } + + /** + * Verify that the user exists and the password is value. + * + * @param customerID + * The customer ID + * @param password + * The password for the customer ID + * @return String with a results message. + */ + public String verifyUserAndPassword(String customerID, String password) { + // Try to get customer. + String results = null; + Customer customer = null; + + customer = em.find(Customer.class, customerID); + + // Does customer exist? + if (customer != null) { + if (!customer.verifyPassword(password)) // Is password correct? + { + results = "\nPassword does not match for : " + customerID; + Util.debug("Password given does not match for userid=" + customerID); + } + } else // Customer was not found. + { + results = "\nCould not find account for : " + customerID; + Util.debug("customer " + customerID + " NOT found"); + } + + return results; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/EMailMessage.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/EMailMessage.java new file mode 100755 index 00000000..aed887a5 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/EMailMessage.java @@ -0,0 +1,57 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +/** + * This class encapsulates the info needed to send an email message. This object is passed to the + * Mailer EJB sendMail() method. + */ +public class EMailMessage implements java.io.Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + private String subject; + private String htmlContents; + private String emailReceiver; + + public EMailMessage(String subject, String htmlContents, String emailReceiver) { + this.subject = subject; + this.htmlContents = htmlContents; + this.emailReceiver = emailReceiver; + } + + // subject field of email message + public String getSubject() { + return subject; + } + + // Email address of recipient of email message + public String getEmailReceiver() { + return emailReceiver; + } + + // contents of email message + public String getHtmlContents() { + return htmlContents; + } + + public String toString() { + return " subject=" + subject + " " + emailReceiver + " " + htmlContents; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerAppException.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerAppException.java new file mode 100755 index 00000000..d55cca99 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerAppException.java @@ -0,0 +1,37 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +/** + * MailerAppException extends the standard Exception. This is thrown by the mailer component when + * there is some failure sending the mail. + */ +public class MailerAppException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public MailerAppException() { + } + + public MailerAppException(String str) { + super(str); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerBean.java new file mode 100755 index 00000000..b4e0d6e3 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/MailerBean.java @@ -0,0 +1,137 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; +import java.util.Date; + +import javax.annotation.Resource; +import javax.enterprise.context.Dependent; +import javax.inject.Named; +import javax.mail.Message; +import javax.mail.Multipart; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeBodyPart; +import javax.mail.internet.MimeMessage; +import javax.mail.internet.MimeMultipart; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import com.ibm.websphere.samples.pbw.jpa.Customer; +import com.ibm.websphere.samples.pbw.jpa.Order; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * MailerBean provides a transactional facade for access to Order information and notification of + * the buyer of order state. + * + */ + +@Named(value = "mailerbean") +@Dependent + +public class MailerBean implements Serializable { + private static final long serialVersionUID = 1L; + // public static final String MAIL_SESSION = "java:comp/env/mail/PlantsByWebSphere"; + @Resource(name = "mail/PlantsByWebSphere") + Session mailSession; + + @PersistenceContext(unitName = "PBW") + + EntityManager em; + + /** + * Create the email message. + * + * @param orderKey + * The order number. + * @return The email message. + */ + private String createMessage(String orderKey) { + Util.debug("creating email message for order:" + orderKey); + StringBuffer msg = new StringBuffer(); + Order order = em.find(Order.class, orderKey); + msg.append("Thank you for your order " + orderKey + ".\n"); + msg.append("Your Plants By WebSphere order will be shipped to:\n"); + msg.append(" " + order.getShipName() + "\n"); + msg.append(" " + order.getShipAddr1() + " " + order.getShipAddr2() + "\n"); + msg.append(" " + order.getShipCity() + ", " + order.getShipState() + " " + order.getShipZip() + "\n\n"); + msg.append("Please save it for your records.\n"); + return msg.toString(); + } + + /** + * Create the Subject line. + * + * @param orderKey + * The order number. + * @return The Order number string. + */ + private String createSubjectLine(String orderKey) { + StringBuffer msg = new StringBuffer(); + msg.append("Your order number " + orderKey); + + return msg.toString(); + } + + /** + * Create a mail message and send it. + * + * @param customerInfo + * Customer information. + * @param orderKey + * @throws MailerAppException + */ + public void createAndSendMail(Customer customerInfo, String orderKey) throws MailerAppException { + try { + EMailMessage eMessage = new EMailMessage(createSubjectLine(orderKey), createMessage(orderKey), + customerInfo.getCustomerID()); + + Util.debug("Sending message" + "\nTo: " + eMessage.getEmailReceiver() + "\nSubject: " + + eMessage.getSubject() + "\nContents: " + eMessage.getHtmlContents()); + + Util.debug("Sending message" + "\nTo: " + eMessage.getEmailReceiver() + "\nSubject: " + + eMessage.getSubject() + "\nContents: " + eMessage.getHtmlContents()); + + MimeMessage msg = new MimeMessage(mailSession); + msg.setFrom(); + + msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(eMessage.getEmailReceiver(), false)); + + msg.setSubject(eMessage.getSubject()); + MimeBodyPart mbp = new MimeBodyPart(); + mbp.setText(eMessage.getHtmlContents(), "us-ascii"); + msg.setHeader("X-Mailer", "JavaMailer"); + Multipart mp = new MimeMultipart(); + mp.addBodyPart(mbp); + msg.setContent(mp); + msg.setSentDate(new Date()); + + Transport.send(msg); + Util.debug("Mail sent successfully."); + + } catch (Exception e) { + + Util.debug("Error sending mail. Have mail resources been configured correctly?"); + Util.debug("createAndSendMail exception : " + e); + e.printStackTrace(); + throw new MailerAppException("Failure while sending mail"); + } + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/NoSupplierException.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/NoSupplierException.java new file mode 100755 index 00000000..3b75308d --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/NoSupplierException.java @@ -0,0 +1,35 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.bean; + +public class NoSupplierException extends Exception { + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Method NoSupplierException + * + * @param message + */ + public NoSupplierException(String message) { + super(message); + return; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/PopulateDBBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/PopulateDBBean.java new file mode 100644 index 00000000..3d05ba66 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/PopulateDBBean.java @@ -0,0 +1,23 @@ +package com.ibm.websphere.samples.pbw.bean; + +import javax.annotation.PostConstruct; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import javax.inject.Inject; + +import com.ibm.websphere.samples.pbw.utils.Util; + +@Singleton +@Startup +public class PopulateDBBean { + + @Inject + ResetDBBean dbBean; + + @PostConstruct + public void initDB() { + Util.debug("Initializing database..."); + dbBean.populateDB(); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ResetDBBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ResetDBBean.java new file mode 100755 index 00000000..41e4af03 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ResetDBBean.java @@ -0,0 +1,343 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2004,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Serializable; +import java.net.URL; +import java.util.Vector; + +import javax.annotation.Resource; +import javax.annotation.security.RolesAllowed; +import javax.enterprise.context.Dependent; +import javax.inject.Inject; +import javax.inject.Named; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.PersistenceContextType; +import javax.persistence.Query; +import javax.persistence.SynchronizationType; +import javax.transaction.HeuristicMixedException; +import javax.transaction.HeuristicRollbackException; +import javax.transaction.NotSupportedException; +import javax.transaction.RollbackException; +import javax.transaction.SystemException; +import javax.transaction.Transactional; +import javax.transaction.UserTransaction; + +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * ResetDBBean provides a transactional and secure facade to reset all the database information for + * the PlantsByWebSphere application. + */ + +@Named(value = "resetbean") +@Dependent +@RolesAllowed("SampAdmin") +public class ResetDBBean implements Serializable { + + @Inject + private CatalogMgr catalog; + @Inject + private CustomerMgr customer; + @Inject + private ShoppingCartBean cart; + @Inject + private BackOrderMgr backOrderStock; + @Inject + private SuppliersBean suppliers; + + @PersistenceContext(unitName = "PBW") + EntityManager em; + + @Resource + UserTransaction tx; + + public void resetDB() { + deleteAll(); + populateDB(); + } + + /** + * @param itemID + * @param fileName + * @param catalog + * @throws FileNotFoundException + * @throws IOException + */ + public static void addImage(String itemID, + String fileName, + CatalogMgr catalog) throws FileNotFoundException, IOException { + URL url = Thread.currentThread().getContextClassLoader().getResource("resources/images/" + fileName); + Util.debug("URL: " + url); + fileName = url.getPath(); + Util.debug("Fully-qualified Filename: " + fileName); + File imgFile = new File(fileName); + // Open the input file as a stream of bytes + FileInputStream fis = new FileInputStream(imgFile); + DataInputStream dis = new DataInputStream(fis); + int dataSize = dis.available(); + byte[] data = new byte[dataSize]; + dis.readFully(data); + catalog.setItemImageBytes(itemID, data); + } + + public void populateDB() { + /** + * Populate INVENTORY table with text + */ + Util.debug("Populating INVENTORY table with text..."); + try { + String[] values = Util.getProperties("inventory"); + for (int index = 0; index < values.length; index++) { + Util.debug("Found INVENTORY property values: " + values[index]); + String[] fields = Util.readTokens(values[index], "|"); + String id = fields[0]; + String name = fields[1]; + String heading = fields[2]; + String descr = fields[3]; + String pkginfo = fields[4]; + String image = fields[5]; + float price = new Float(fields[6]).floatValue(); + float cost = new Float(fields[7]).floatValue(); + int quantity = new Integer(fields[8]).intValue(); + int category = new Integer(fields[9]).intValue(); + String notes = fields[10]; + boolean isPublic = new Boolean(fields[11]).booleanValue(); + Util.debug("Populating INVENTORY with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + Util.debug(fields[10]); + Util.debug(fields[11]); + Inventory storeItem = new Inventory(id, name, heading, descr, pkginfo, image, price, cost, quantity, + category, notes, isPublic); + catalog.addItem(storeItem); + addImage(id, image, catalog); + } + Util.debug("INVENTORY table populated with text..."); + } catch (Exception e) { + Util.debug("Unable to populate INVENTORY table with text data: " + e); + e.printStackTrace(); + } + /** + * Populate CUSTOMER table with text + */ + Util.debug("Populating CUSTOMER table with default values..."); + try { + String[] values = Util.getProperties("customer"); + Util.debug("Found CUSTOMER properties: " + values[0]); + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String customerID = fields[0]; + String password = fields[1]; + String firstName = fields[2]; + String lastName = fields[3]; + String addr1 = fields[4]; + String addr2 = fields[5]; + String addrCity = fields[6]; + String addrState = fields[7]; + String addrZip = fields[8]; + String phone = fields[9]; + Util.debug("Populating CUSTOMER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + customer.createCustomer(customerID, password, firstName, lastName, addr1, addr2, addrCity, addrState, addrZip, phone); + } + } catch (Exception e) { + Util.debug("Unable to populate CUSTOMER table with text data: " + e); + e.printStackTrace(); + } + /** + * Populate ORDER table with text + */ + Util.debug("Populating ORDER table with default values..."); + try { + String[] values = Util.getProperties("order"); + Util.debug("Found ORDER properties: " + values[0]); + if (values[0] != null && values.length > 0) { + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + if (fields != null && fields.length >= 21) { + String customerID = fields[0]; + String billName = fields[1]; + String billAddr1 = fields[2]; + String billAddr2 = fields[3]; + String billCity = fields[4]; + String billState = fields[5]; + String billZip = fields[6]; + String billPhone = fields[7]; + String shipName = fields[8]; + String shipAddr1 = fields[9]; + String shipAddr2 = fields[10]; + String shipCity = fields[11]; + String shipState = fields[12]; + String shipZip = fields[13]; + String shipPhone = fields[14]; + int shippingMethod = Integer.parseInt(fields[15]); + String creditCard = fields[16]; + String ccNum = fields[17]; + String ccExpireMonth = fields[18]; + String ccExpireYear = fields[19]; + String cardHolder = fields[20]; + Vector items = new Vector(); + Util.debug("Populating ORDER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + Util.debug(fields[10]); + Util.debug(fields[11]); + Util.debug(fields[12]); + Util.debug(fields[13]); + Util.debug(fields[14]); + Util.debug(fields[15]); + Util.debug(fields[16]); + Util.debug(fields[17]); + Util.debug(fields[18]); + Util.debug(fields[19]); + Util.debug(fields[20]); + cart.createOrder(customerID, billName, billAddr1, billAddr2, billCity, billState, billZip, billPhone, shipName, shipAddr1, shipAddr2, shipCity, shipState, shipZip, shipPhone, creditCard, ccNum, ccExpireMonth, ccExpireYear, cardHolder, shippingMethod, items); + } else { + Util.debug("Property does not contain enough fields: " + values[index]); + Util.debug("Fields found were: " + fields); + } + } + } + // stmt.executeUpdate(" INSERT INTO ORDERITEM(INVENTORYID, NAME, PKGINFO, PRICE, COST, + // CATEGORY, QUANTITY, SELLDATE, ORDER_ORDERID) VALUES ('A0001', 'Bulb Digger', + // 'Assembled', 12.0, 5.0, 3, 900, '01054835419625', '1')"); + } catch (Exception e) { + Util.debug("Unable to populate ORDERITEM table with text data: " + e); + e.printStackTrace(); + e.printStackTrace(); + } + /** + * Populate BACKORDER table with text + */ + Util.debug("Populating BACKORDER table with default values..."); + try { + String[] values = Util.getProperties("backorder"); + Util.debug("Found BACKORDER properties: " + values[0]); + // Inserting backorders + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String inventoryID = fields[0]; + int amountToOrder = new Integer(fields[1]).intValue(); + int maximumItems = new Integer(fields[2]).intValue(); + Util.debug("Populating BACKORDER with following values: "); + Util.debug(inventoryID); + Util.debug("amountToOrder -> " + amountToOrder); + Util.debug("maximumItems -> " + maximumItems); + backOrderStock.createBackOrder(inventoryID, amountToOrder, maximumItems); + } + } catch (Exception e) { + Util.debug("Unable to populate BACKORDER table with text data: " + e); + e.printStackTrace(); + } + /** + * Populate SUPPLIER table with text + */ + Util.debug("Populating SUPPLIER table with default values..."); + try { + String[] values = Util.getProperties("supplier"); + Util.debug("Found SUPPLIER properties: " + values[0]); + // Inserting Suppliers + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String supplierID = fields[0]; + String name = fields[1]; + String address = fields[2]; + String city = fields[3]; + String state = fields[4]; + String zip = fields[5]; + String phone = fields[6]; + String url = fields[7]; + Util.debug("Populating SUPPLIER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + suppliers.createSupplier(supplierID, name, address, city, state, zip, phone, url); + } + } catch (Exception e) { + Util.debug("Unable to populate SUPPLIER table with text data: " + e); + e.printStackTrace(); + } + } + + @Transactional + public void deleteAll() { + try { + Query q = em.createNamedQuery("removeAllOrders"); + q.executeUpdate(); + q = em.createNamedQuery("removeAllInventory"); + q.executeUpdate(); + // q=em.createNamedQuery("removeAllIdGenerator"); + // q.executeUpdate(); + q = em.createNamedQuery("removeAllCustomers"); + q.executeUpdate(); + q = em.createNamedQuery("removeAllOrderItem"); + q.executeUpdate(); + q = em.createNamedQuery("removeAllBackOrder"); + q.executeUpdate(); + q = em.createNamedQuery("removeAllSupplier"); + q.executeUpdate(); + em.flush(); + Util.debug("Deleted all data from database"); + } catch (Exception e) { + Util.debug("ResetDB(deleteAll) -- Error deleting data from the database: " + e); + e.printStackTrace(); + try { + tx.setRollbackOnly(); + } catch (IllegalStateException | SystemException ignore) { + } + } + } + +} \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartBean.java new file mode 100755 index 00000000..581fa265 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartBean.java @@ -0,0 +1,347 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; + +import javax.enterprise.context.SessionScoped; +import javax.persistence.EntityManager; +import javax.persistence.LockModeType; +import javax.persistence.PersistenceContext; +import javax.transaction.Transactional; + +import com.ibm.websphere.samples.pbw.jpa.BackOrder; +import com.ibm.websphere.samples.pbw.jpa.Customer; +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.jpa.Order; +import com.ibm.websphere.samples.pbw.jpa.OrderItem; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * ShopingCartBean provides a transactional facade for order collection and processing. + * + */ + +@Transactional +@SessionScoped +public class ShoppingCartBean implements Serializable { + + @PersistenceContext(unitName = "PBW") + EntityManager em; + + private ArrayList items = new ArrayList(); + + /** + * Add an item to the cart. + * + * @param new_item + * Item to add to the cart. + */ + public void addItem(Inventory new_item) { + boolean added = false; + // If the same item is already in the cart, just increase the quantity. + for (Inventory old_item : items) { + if (old_item.getID().equals(new_item.getID())) { + old_item.setQuantity(old_item.getQuantity() + new_item.getQuantity()); + added = true; + break; + } + } + // Add this item to shopping cart, if it is a brand new item. + if (!added) + items.add(new_item); + } + + /** + * Remove an item from the cart. + * + * @param item + * Item to remove from cart. + */ + public void removeItem(Inventory item) { + for (Inventory i : items) { + if (item.equals(i)) { + items.remove(i); + break; + } + } + } + + /** + * Remove all items from the cart. + */ + public void removeAllItems() { + items = new ArrayList(); + } + + /** + * Remove zero quantity items. + */ + public void removeZeroQuantityItems() { + ArrayList newItems = new ArrayList(); + + for (Inventory i : items) { + if (i.getQuantity() > 0) { + newItems.add(i); + } + } + + items = newItems; + } + + /** + * Get the items in the shopping cart. + * + * @return A Collection of ShoppingCartItems. + */ + public ArrayList getItems() { + return items; + } + + /** + * Set the items in the shopping cart. + * + * @param items + * A Vector of ShoppingCartItem's. + */ + public void setItems(Collection items) { + this.items = new ArrayList(items); + } + + /** + * Get the contents of the shopping cart. + * + * @return The contents of the shopping cart. / public ShoppingCartContents getCartContents() { + * ShoppingCartContents cartContents = new ShoppingCartContents(); // Fill it with data. + * for (int i = 0; i < items.size(); i++) { cartContents.addItem((ShoppingCartItem) + * items.get(i)); } return cartContents; } + */ + + /** + * Create a shopping cart. + * + * @param cartContents + * Contents to populate cart with. / public void setCartContents(ShoppingCartContents + * cartContents) { items = new ArrayList(); int qty; String + * inventoryID; ShoppingCartItem si; Inventory inv; for (int i = 0; i < + * cartContents.size(); i++) { inventoryID = cartContents.getInventoryID(i); qty = + * cartContents.getQuantity(inventoryID); inv = em.find(Inventory.class, + * inventoryID); // clone so we can use Qty as qty to purchase, not inventory in + * stock si = new ShoppingCartItem(inv); si.setQuantity(qty); addItem(si); } } + */ + + /** + * Get the cost of all items in the shopping cart. + * + * @return The total cost of all items in the shopping cart. + */ + public float getSubtotalCost() { + float f = 0.0F; + + for (Inventory item : items) { + f += item.getPrice() * (float) item.getQuantity(); + } + return f; + } + + /** + * Method checkInventory. Check the inventory level of a store item. Order additional inventory + * when necessary. + * + * @param si + * - Store item + */ + public void checkInventory(Inventory si) { + Util.debug("ShoppingCart.checkInventory() - checking Inventory quantity of item: " + si.getID()); + Inventory inv = getInventoryItem(si.getID()); + + /** + * Decrease the quantity of this inventory item. + * + * @param quantity + * The number to decrease the inventory by. + * @return The number of inventory items removed. + */ + int quantity = si.getQuantity(); + int minimumItems = inv.getMinThreshold(); + + int amountToOrder = 0; + Util.debug("ShoppingCartBean:checkInventory() - Decreasing inventory item " + inv.getInventoryId()); + int quantityNotFilled = 0; + if (inv.getQuantity() < 1) { + quantityNotFilled = quantity; + } else if (inv.getQuantity() < quantity) { + quantityNotFilled = quantity - inv.getQuantity(); + } + + // When quantity becomes < 0, this will be to determine the + // quantity of unfilled orders due to insufficient stock. + inv.setQuantity(inv.getQuantity() - quantity); + + // Check to see if more inventory needs to be ordered from the supplier + // based on a set minimum Threshold + if (inv.getQuantity() < minimumItems) { + // Calculate the amount of stock to order from the supplier + // to get the inventory up to the maximum. + amountToOrder = quantityNotFilled; + backOrder(inv, amountToOrder); + } + + } + + /** + * Create an order with contents of a shopping cart. + * + * @param customerID + * customer's ID + * @param billName + * billing name + * @param billAddr1 + * billing address line 1 + * @param billAddr2 + * billing address line 2 + * @param billCity + * billing address city + * @param billState + * billing address state + * @param billZip + * billing address zip code + * @param billPhone + * billing phone + * @param shipName + * shippng name + * @param shipAddr1 + * shippng address line 1 + * @param shipAddr2 + * shippng address line 2 + * @param shipCity + * shippng address city + * @param shipState + * shippng address state + * @param shipZip + * shippng address zip code + * @param shipPhone + * shippng phone + * @param creditCard + * credit card + * @param ccNum + * credit card number + * @param ccExpireMonth + * credit card expiration month + * @param ccExpireYear + * credit card expiration year + * @param cardHolder + * credit card holder name + * @param shippingMethod + * int of shipping method used + * @param items + * vector of StoreItems ordered + * @return OrderInfo + */ + public Order createOrder(String customerID, + String billName, + String billAddr1, + String billAddr2, + String billCity, + String billState, + String billZip, + String billPhone, + String shipName, + String shipAddr1, + String shipAddr2, + String shipCity, + String shipState, + String shipZip, + String shipPhone, + String creditCard, + String ccNum, + String ccExpireMonth, + String ccExpireYear, + String cardHolder, + int shippingMethod, + Collection items) { + Order order = null; + Util.debug("ShoppingCartBean.createOrder: Creating Order"); + Collection orderitems = new ArrayList(); + for (Inventory si : items) { + Inventory inv = em.find(Inventory.class, si.getID()); + OrderItem oi = new OrderItem(inv); + oi.setQuantity(si.getQuantity()); + orderitems.add(oi); + } + Customer c = em.find(Customer.class, customerID); + order = new Order(c, billName, billAddr1, billAddr2, billCity, billState, billZip, billPhone, shipName, + shipAddr1, shipAddr2, shipCity, shipState, shipZip, shipPhone, creditCard, ccNum, ccExpireMonth, + ccExpireYear, cardHolder, shippingMethod, orderitems); + em.persist(order); + em.flush(); + // store the order items + for (OrderItem o : orderitems) { + o.setOrder(order); + o.updatePK(); + em.persist(o); + } + em.flush(); + + return order; + } + + public int getSize() { + return getItems().size(); + } + + /* + * Get the inventory item. + * + * @param id of inventory item. + * + * @return an inventory bean. + */ + private Inventory getInventoryItem(String inventoryID) { + Inventory inv = null; + inv = em.find(Inventory.class, inventoryID); + return inv; + } + + /* + * Create a BackOrder of this inventory item. + * + * @param quantity The number of the inventory item to be backordered + */ + private void backOrder(Inventory inv, int amountToOrder) { + BackOrder b = em.find(BackOrder.class, inv.getInventoryId()); + if (b == null) { + // create a new backorder if none exists + BackOrder newBO = new BackOrder(inv, amountToOrder); + em.persist(newBO); + em.flush(); + inv.setBackOrder(newBO); + } else { + // update the backorder with the new quantity + int quantity = b.getQuantity(); + quantity += amountToOrder; + em.lock(b, LockModeType.WRITE); + em.refresh(b); + b.setQuantity(quantity); + em.flush(); + inv.setBackOrder(b); + } + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartContent.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartContent.java new file mode 100755 index 00000000..3b45d57c --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/ShoppingCartContent.java @@ -0,0 +1,97 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.util.Enumeration; +import java.util.Hashtable; + +import com.ibm.websphere.samples.pbw.jpa.Inventory; + +/** + * A class to hold a shopping cart's contents. + */ +public class ShoppingCartContent implements java.io.Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + private Hashtable table = null; + + public ShoppingCartContent() { + table = new Hashtable(); + } + + /** Add the item to the shopping cart. */ + public void addItem(Inventory si) { + table.put(si.getID(), new Integer(si.getQuantity())); + } + + /** Update the item in the shopping cart. */ + public void updateItem(Inventory si) { + table.put(si.getID(), new Integer(si.getQuantity())); + } + + /** Remove the item from the shopping cart. */ + public void removeItem(Inventory si) { + table.remove(si.getID()); + } + + /** + * Return the number of items in the cart. + * + * @return The number of items in the cart. + */ + public int size() { + return table.size(); + } + + /** + * Return the inventory ID at the index given. The first element is at index 0, the second at + * index 1, and so on. + * + * @return The inventory ID at the index, or NULL if not present. + */ + public String getInventoryID(int index) { + String retval = null; + String inventoryID; + int cnt = 0; + for (Enumeration myEnum = table.keys(); myEnum.hasMoreElements(); cnt++) { + inventoryID = (String) myEnum.nextElement(); + if (index == cnt) { + retval = inventoryID; + break; + } + } + return retval; + } + + /** + * Return the quantity for the inventory ID given. + * + * @return The quantity for the inventory ID given.. + * + */ + public int getQuantity(String inventoryID) { + Integer quantity = (Integer) table.get(inventoryID); + + if (quantity == null) + return 0; + else + return quantity.intValue(); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/SuppliersBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/SuppliersBean.java new file mode 100755 index 00000000..6c4c5883 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/bean/SuppliersBean.java @@ -0,0 +1,144 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2004,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.bean; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Iterator; + +import javax.enterprise.context.Dependent; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import com.ibm.websphere.samples.pbw.jpa.Supplier; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Bean implementation class for Enterprise Bean: Suppliers + */ +@Dependent +public class SuppliersBean implements Serializable { + + @PersistenceContext(unitName = "PBW") + EntityManager em; + + /** + * @param supplierID + * @param name + * @param street + * @param city + * @param state + * @param zip + * @param phone + * @param url + */ + public void createSupplier(String supplierID, + String name, + String street, + String city, + String state, + String zip, + String phone, + String url) { + try { + Util.debug("SuppliersBean.createSupplier() - Entered"); + Supplier supplier = null; + supplier = em.find(Supplier.class, supplierID); + if (supplier == null) { + Util.debug("SuppliersBean.createSupplier() - supplier doesn't exist."); + Util.debug("SuppliersBean.createSupplier() - Creating Supplier for SupplierID: " + supplierID); + supplier = new Supplier(supplierID, name, street, city, state, zip, phone, url); + em.persist(supplier); + } + } catch (Exception e) { + Util.debug("SuppliersBean.createSupplier() - Exception: " + e); + } + } + + /** + * @return Supplier + */ + public Supplier getSupplier() { + // Retrieve the first Supplier Info + try { + Collection suppliers = this.findSuppliers(); + if (suppliers != null) { + Util.debug("AdminServlet.getSupplierInfo() - Supplier found!"); + Iterator i = suppliers.iterator(); + if (i.hasNext()) { + return (Supplier) i.next(); + } + } + } catch (Exception e) { + Util.debug("AdminServlet.getSupplierInfo() - Exception:" + e); + } + return null; + } + + /** + * @param supplierID + * @param name + * @param street + * @param city + * @param state + * @param zip + * @param phone + * @param url + * @return supplierInfo + */ + public Supplier updateSupplier(String supplierID, + String name, + String street, + String city, + String state, + String zip, + String phone, + String url) { + Supplier supplier = null; + try { + Util.debug("SuppliersBean.updateSupplier() - Entered"); + supplier = em.find(Supplier.class, supplierID); + if (supplier != null) { + // Create a new Supplier if there is NOT an existing Supplier. + // supplier = getSupplierLocalHome().findByPrimaryKey(new SupplierKey(supplierID)); + supplier.setName(name); + supplier.setStreet(street); + supplier.setCity(city); + supplier.setUsstate(state); + supplier.setZip(zip); + supplier.setPhone(phone); + supplier.setUrl(url); + } else { + Util.debug("SuppliersBean.updateSupplier() - supplier doesn't exist."); + Util.debug("SuppliersBean.updateSupplier() - Couldn't update Supplier for SupplierID: " + supplierID); + } + } catch (Exception e) { + Util.debug("SuppliersBean.createSupplier() - Exception: " + e); + } + return (supplier); + } + + /** + * @return suppliers + */ + @SuppressWarnings("unchecked") + private Collection findSuppliers() { + Query q = em.createNamedQuery("findAllSuppliers"); + return q.getResultList(); + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/BackOrder.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/BackOrder.java new file mode 100755 index 00000000..e110c1d6 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/BackOrder.java @@ -0,0 +1,135 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.TableGenerator; + +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Bean mapping for BACKORDER table. + */ +@Entity(name = "BackOrder") +@Table(name = "BACKORDER", schema = "APP") +@NamedQueries({ @NamedQuery(name = "findAllBackOrders", query = "select b from BackOrder b"), + @NamedQuery(name = "findByInventoryID", query = "select b from BackOrder b where ((b.inventory.inventoryId = :id) and (b.status = 'Order Stock'))"), + @NamedQuery(name = "removeAllBackOrder", query = "delete from BackOrder") }) +public class BackOrder { + @Id + @GeneratedValue(strategy = GenerationType.TABLE, generator = "BackOrderSeq") + @TableGenerator(name = "BackOrderSeq", table = "IDGENERATOR", pkColumnName = "IDNAME", pkColumnValue = "BACKORDER", valueColumnName = "IDVALUE") + private String backOrderID; + private int quantity; + private String status; + private long lowDate; + private long orderDate; + private String supplierOrderID; // missing table + + // relationships + @OneToOne + @JoinColumn(name = "INVENTORYID") + private Inventory inventory; + + public BackOrder() { + } + + public BackOrder(String backOrderID) { + setBackOrderID(backOrderID); + } + + public BackOrder(Inventory inventory, int quantity) { + this.setInventory(inventory); + this.setQuantity(quantity); + this.setStatus(Util.STATUS_ORDERSTOCK); + this.setLowDate(System.currentTimeMillis()); + } + + public String getBackOrderID() { + return backOrderID; + } + + public void setBackOrderID(String backOrderID) { + this.backOrderID = backOrderID; + } + + public long getLowDate() { + return lowDate; + } + + public void setLowDate(long lowDate) { + this.lowDate = lowDate; + } + + public long getOrderDate() { + return orderDate; + } + + public void setOrderDate(long orderDate) { + this.orderDate = orderDate; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public void increateQuantity(int delta) { + if (!(status.equals(Util.STATUS_ORDERSTOCK))) { + Util.debug("BackOrderMgr.createBackOrder() - Backorders found but have already been ordered from the supplier"); + throw new RuntimeException("cannot increase order size for orders already in progress"); + } + // Increase the BackOrder quantity for an existing Back Order. + quantity = quantity + delta; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getSupplierOrderID() { + return supplierOrderID; + } + + public void setSupplierOrderID(String supplierOrderID) { + this.supplierOrderID = supplierOrderID; + } + + public Inventory getInventory() { + return inventory; + } + + public void setInventory(Inventory inventory) { + this.inventory = inventory; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Customer.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Customer.java new file mode 100755 index 00000000..61168c82 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Customer.java @@ -0,0 +1,204 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +/** + * Customer is the bean mapping for the CUSTOMER table. + * + * @see Customer + */ +@Entity(name = "Customer") +@Table(name = "CUSTOMER", schema = "APP") +@NamedQueries({ @NamedQuery(name = "removeAllCustomers", query = "delete from Customer") }) +public class Customer { + @Id + private String customerID; + private String password; + + @NotNull + @Size(min = 1, message = "First name must include at least one letter.") + private String firstName; + @NotNull + @Size(min = 1, message = "Last name must include at least one letter.") + private String lastName; + @NotNull + @Size(min = 1, message = "Address must include at least one letter.") + private String addr1; + private String addr2; + @NotNull + @Size(min = 1, message = "City name must include at least one letter.") + private String addrCity; + @NotNull + @Size(min = 2, message = "State must include at least two letters.") + private String addrState; + @Pattern(regexp = "\\d{5}", message = "Zip code does not have 5 digits.") + private String addrZip; + @NotNull + @Pattern(regexp = "\\d{3}-\\d{3}-\\d{4}", message = "Phone number does not match xxx-xxx-xxxx.") + private String phone; + + public Customer() { + } + + /** + * Create a new Customer. + * + * @param key + * CustomerKey + * @param password + * Password used for this customer account. + * @param firstName + * First name of the customer. + * @param lastName + * Last name of the customer + * @param addr1 + * Street address of the customer + * @param addr2 + * Street address of the customer + * @param addrCity + * City + * @param addrState + * State + * @param addrZip + * Zip code + * @param phone + * Phone number + */ + public Customer(String key, String password, String firstName, String lastName, String addr1, String addr2, + String addrCity, String addrState, String addrZip, String phone) { + this.setCustomerID(key); + this.setPassword(password); + this.setFirstName(firstName); + this.setLastName(lastName); + this.setAddr1(addr1); + this.setAddr2(addr2); + this.setAddrCity(addrCity); + this.setAddrState(addrState); + this.setAddrZip(addrZip); + this.setPhone(phone); + } + + /** + * Verify password. + * + * @param password + * value to be checked. + * @return True, if password matches one stored. + */ + public boolean verifyPassword(String password) { + return this.getPassword().equals(password); + } + + /** + * Get the customer's full name. + * + * @return String of customer's full name. + */ + public String getFullName() { + return this.getFirstName() + " " + this.getLastName(); + } + + public String getAddr1() { + return addr1; + } + + public void setAddr1(String addr1) { + this.addr1 = addr1; + } + + public String getAddr2() { + return addr2; + } + + public void setAddr2(String addr2) { + this.addr2 = addr2; + } + + public String getAddrCity() { + return addrCity; + } + + public void setAddrCity(String addrCity) { + this.addrCity = addrCity; + } + + public String getAddrState() { + return addrState; + } + + public void setAddrState(String addrState) { + this.addrState = addrState; + } + + public String getAddrZip() { + return addrZip; + } + + public void setAddrZip(String addrZip) { + this.addrZip = addrZip; + } + + public String getCustomerID() { + return customerID; + } + + public void setCustomerID(String customerID) { + this.customerID = customerID; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Inventory.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Inventory.java new file mode 100755 index 00000000..ec5973c0 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Inventory.java @@ -0,0 +1,312 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; +import javax.persistence.Version; + +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Inventory is the bean mapping for the INVENTORY table. It provides information about products the + * store has for sale. + * + * @see Inventory + */ +@Entity(name = "Inventory") +@Table(name = "INVENTORY", schema = "APP") +@NamedQueries({ + @NamedQuery(name = "getItemsByCategory", query = "select i from Inventory i where i.category = :category ORDER BY i.inventoryId"), + @NamedQuery(name = "getItemsLikeName", query = "select i from Inventory i where i.name like :name"), + @NamedQuery(name = "removeAllInventory", query = "delete from Inventory") }) +public class Inventory implements Cloneable, java.io.Serializable { + private static final long serialVersionUID = 1L; + private static final int DEFAULT_MINTHRESHOLD = 50; + private static final int DEFAULT_MAXTHRESHOLD = 200; + @Id + private String inventoryId; + private String name; + private String heading; + private String description; + private String pkginfo; + private String image; + private byte[] imgbytes; + private float price; + private float cost; + private int quantity; + private int category; + private String notes; + private boolean isPublic; + private int minThreshold; + private int maxThreshold; + + @Version + private long version; + + @Transient + private BackOrder backOrder; + + public Inventory() { + } + + /** + * Create a new Inventory. + * + * @param key + * Inventory Key + * @param name + * Name of inventory item. + * @param heading + * Description heading of inventory item. + * @param desc + * Description of inventory item. + * @param pkginfo + * Package info of inventory item. + * @param image + * Image of inventory item. + * @param price + * Price of inventory item. + * @param cost + * Cost of inventory item. + * @param quantity + * Quantity of inventory items in stock. + * @param category + * Category of inventory item. + * @param notes + * Notes of inventory item. + * @param isPublic + * Access permission of inventory item. + */ + public Inventory(String key, String name, String heading, String desc, String pkginfo, String image, float price, + float cost, int quantity, int category, String notes, boolean isPublic) { + this.setInventoryId(key); + Util.debug("creating new Inventory, inventoryId=" + this.getInventoryId()); + this.setName(name); + this.setHeading(heading); + this.setDescription(desc); + this.setPkginfo(pkginfo); + this.setImage(image); + this.setPrice(price); + this.setCost(cost); + this.setQuantity(quantity); + this.setCategory(category); + this.setNotes(notes); + this.setIsPublic(isPublic); + this.setMinThreshold(DEFAULT_MINTHRESHOLD); + this.setMaxThreshold(DEFAULT_MAXTHRESHOLD); + + } + + /** + * Create a new Inventory. + * + * @param item + * Inventory to use to make a new inventory item. + */ + public Inventory(Inventory item) { + this.setInventoryId(item.getInventoryId()); + this.setName(item.getName()); + this.setHeading(item.getHeading()); + this.setDescription(item.getDescription()); + this.setPkginfo(item.getPkginfo()); + this.setImage(item.getImage()); + this.setPrice(item.getPrice()); + this.setCost(item.getCost()); + this.setQuantity(item.getQuantity()); + this.setCategory(item.getCategory()); + this.setNotes(item.getNotes()); + this.setMinThreshold(DEFAULT_MINTHRESHOLD); + this.setMaxThreshold(DEFAULT_MAXTHRESHOLD); + + setIsPublic(item.isPublic()); + + // does not clone BackOrder info + } + + /** + * Increase the quantity of this inventory item. + * + * @param quantity + * The number to increase the inventory by. + */ + public void increaseInventory(int quantity) { + this.setQuantity(this.getQuantity() + quantity); + } + + public int getCategory() { + return category; + } + + public void setCategory(int category) { + this.category = category; + } + + public float getCost() { + return cost; + } + + public void setCost(float cost) { + this.cost = cost; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getHeading() { + return heading; + } + + public void setHeading(String heading) { + this.heading = heading; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + + public String getPkginfo() { + return pkginfo; + } + + public void setPkginfo(String pkginfo) { + this.pkginfo = pkginfo; + } + + public float getPrice() { + return price; + } + + public void setPrice(float price) { + this.price = price; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public int getMaxThreshold() { + return maxThreshold; + } + + public void setMaxThreshold(int maxThreshold) { + this.maxThreshold = maxThreshold; + } + + public int getMinThreshold() { + return minThreshold; + } + + public void setMinThreshold(int minThreshold) { + this.minThreshold = minThreshold; + } + + public String getInventoryId() { + return inventoryId; + } + + public void setInventoryId(String id) { + inventoryId = id; + } + + /** + * Same as getInventoryId. Added for compatability with ShoppingCartItem when used by the Client + * XJB sample + * + * @return String ID of the inventory item + */ + public String getID() { + return inventoryId; + } + + /** + * Same as setInventoryId. Added for compatability with ShoppingCartItem when used by the Client + * XJB sample + * + */ + public void setID(String id) { + inventoryId = id; + } + + public boolean isPublic() { + return isPublic; + } + + public void setIsPublic(boolean isPublic) { + this.isPublic = isPublic; + } + + /** Set the inventory item's public availability. */ + public void setPrivacy(boolean isPublic) { + setIsPublic(isPublic); + } + + public byte[] getImgbytes() { + return imgbytes; + } + + public void setImgbytes(byte[] imgbytes) { + this.imgbytes = imgbytes; + } + + public BackOrder getBackOrder() { + return backOrder; + } + + public void setBackOrder(BackOrder backOrder) { + this.backOrder = backOrder; + } + + @Override + public String toString() { + return getClass().getSimpleName() + "{id=" + inventoryId + "}"; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Order.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Order.java new file mode 100755 index 00000000..eefe51e9 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Order.java @@ -0,0 +1,393 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.jpa; + +import java.util.Collection; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.TableGenerator; +import javax.persistence.Transient; + +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Bean mapping for the ORDER1 table. + */ +@Entity(name = "Order") +@Table(name = "ORDER1", schema = "APP") +@NamedQueries({ @NamedQuery(name = "removeAllOrders", query = "delete from Order") }) +public class Order { + public static final String ORDER_INFO_TABLE_NAME = "java:comp/env/jdbc/OrderInfoTableName"; + public static final String ORDER_ITEMS_TABLE_NAME = "java:comp/env/jdbc/OrderItemsTableName"; + + @Id + @GeneratedValue(strategy = GenerationType.TABLE, generator = "OrderSeq") + @TableGenerator(name = "OrderSeq", table = "IDGENERATOR", pkColumnName = "IDNAME", pkColumnValue = "ORDER", valueColumnName = "IDVALUE") + private String orderID; + private String sellDate; + private String billName; + private String billAddr1; + private String billAddr2; + private String billCity; + private String billState; + private String billZip; + private String billPhone; + private String shipName; + private String shipAddr1; + private String shipAddr2; + private String shipCity; + private String shipState; + private String shipZip; + private String shipPhone; + private String creditCard; + private String ccNum; + private String ccExpireMonth; + private String ccExpireYear; + private String cardHolder; + private int shippingMethod; + private float profit; + + @ManyToOne + @JoinColumn(name = "CUSTOMERID") + private Customer customer; + @Transient + private Collection orderItems; + + @Transient + private Collection items = null; + + /** + * Constructor to create an Order. + * + * @param customer + * - customer who created the order + * @param billName + * - billing name + * @param billAddr1 + * - billing address line 1 + * @param billAddr2 + * - billing address line 2 + * @param billCity + * - billing address city + * @param billState + * - billing address state + * @param billZip + * - billing address zip code + * @param billPhone + * - billing phone + * @param shipName + * - shippng name + * @param shipAddr1 + * - shippng address line 1 + * @param shipAddr2 + * - shippng address line 2 + * @param shipCity + * - shippng address city + * @param shipState + * - shippng address state + * @param shipZip + * - shippng address zip code + * @param shipPhone + * - shippng phone + * @param creditCard + * - credit card + * @param ccNum + * - credit card number + * @param ccExpireMonth + * - credit card expiration month + * @param ccExpireYear + * - credit card expiration year + * @param cardHolder + * - credit card holder name + * @param shippingMethod + * int of shipping method used + * @param items + * vector of StoreItems ordered + */ + public Order(Customer customer, String billName, String billAddr1, String billAddr2, String billCity, + String billState, String billZip, String billPhone, String shipName, String shipAddr1, String shipAddr2, + String shipCity, String shipState, String shipZip, String shipPhone, String creditCard, String ccNum, + String ccExpireMonth, String ccExpireYear, String cardHolder, int shippingMethod, + Collection items) { + this.setSellDate(Long.toString(System.currentTimeMillis())); + + // Pad it to 14 digits so sorting works properly. + if (this.getSellDate().length() < 14) { + StringBuffer sb = new StringBuffer(Util.ZERO_14); + sb.replace((14 - this.getSellDate().length()), 14, this.getSellDate()); + this.setSellDate(sb.toString()); + } + + this.setCustomer(customer); + this.setBillName(billName); + this.setBillAddr1(billAddr1); + this.setBillAddr2(billAddr2); + this.setBillCity(billCity); + this.setBillState(billState); + this.setBillZip(billZip); + this.setBillPhone(billPhone); + this.setShipName(shipName); + this.setShipAddr1(shipAddr1); + this.setShipAddr2(shipAddr2); + this.setShipCity(shipCity); + this.setShipState(shipState); + this.setShipZip(shipZip); + this.setShipPhone(shipPhone); + this.setCreditCard(creditCard); + this.setCcNum(ccNum); + this.setCcExpireMonth(ccExpireMonth); + this.setCcExpireYear(ccExpireYear); + this.setCardHolder(cardHolder); + this.setShippingMethod(shippingMethod); + this.items = items; + + // Get profit for total order. + OrderItem oi; + float profit; + profit = 0.0f; + for (Object o : items) { + oi = (OrderItem) o; + profit = profit + (oi.getQuantity() * (oi.getPrice() - oi.getCost())); + oi.setOrder(this); + } + this.setProfit(profit); + } + + public Order(String orderID) { + setOrderID(orderID); + } + + public Order() { + } + + public String getBillAddr1() { + return billAddr1; + } + + public void setBillAddr1(String billAddr1) { + this.billAddr1 = billAddr1; + } + + public String getBillAddr2() { + return billAddr2; + } + + public void setBillAddr2(String billAddr2) { + this.billAddr2 = billAddr2; + } + + public String getBillCity() { + return billCity; + } + + public void setBillCity(String billCity) { + this.billCity = billCity; + } + + public String getBillName() { + return billName; + } + + public void setBillName(String billName) { + this.billName = billName; + } + + public String getBillPhone() { + return billPhone; + } + + public void setBillPhone(String billPhone) { + this.billPhone = billPhone; + } + + public String getBillState() { + return billState; + } + + public void setBillState(String billState) { + this.billState = billState; + } + + public String getBillZip() { + return billZip; + } + + public void setBillZip(String billZip) { + this.billZip = billZip; + } + + public String getCardHolder() { + return cardHolder; + } + + public void setCardHolder(String cardHolder) { + this.cardHolder = cardHolder; + } + + public String getCcExpireMonth() { + return ccExpireMonth; + } + + public void setCcExpireMonth(String ccExpireMonth) { + this.ccExpireMonth = ccExpireMonth; + } + + public String getCcExpireYear() { + return ccExpireYear; + } + + public void setCcExpireYear(String ccExpireYear) { + this.ccExpireYear = ccExpireYear; + } + + public String getCcNum() { + return ccNum; + } + + public void setCcNum(String ccNum) { + this.ccNum = ccNum; + } + + public String getCreditCard() { + return creditCard; + } + + public void setCreditCard(String creditCard) { + this.creditCard = creditCard; + } + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public Collection getItems() { + return items; + } + + public void setItems(Collection items) { + this.items = items; + } + + public String getOrderID() { + return orderID; + } + + public void setOrderID(String orderID) { + this.orderID = orderID; + } + + public Collection getOrderItems() { + return orderItems; + } + + public void setOrderItems(Collection orderItems) { + this.orderItems = orderItems; + } + + public float getProfit() { + return profit; + } + + public void setProfit(float profit) { + this.profit = profit; + } + + public String getSellDate() { + return sellDate; + } + + public void setSellDate(String sellDate) { + this.sellDate = sellDate; + } + + public String getShipAddr1() { + return shipAddr1; + } + + public void setShipAddr1(String shipAddr1) { + this.shipAddr1 = shipAddr1; + } + + public String getShipAddr2() { + return shipAddr2; + } + + public void setShipAddr2(String shipAddr2) { + this.shipAddr2 = shipAddr2; + } + + public String getShipCity() { + return shipCity; + } + + public void setShipCity(String shipCity) { + this.shipCity = shipCity; + } + + public String getShipName() { + return shipName; + } + + public void setShipName(String shipName) { + this.shipName = shipName; + } + + public String getShipPhone() { + return shipPhone; + } + + public void setShipPhone(String shipPhone) { + this.shipPhone = shipPhone; + } + + public int getShippingMethod() { + return shippingMethod; + } + + public void setShippingMethod(int shippingMethod) { + this.shippingMethod = shippingMethod; + } + + public String getShipZip() { + return shipZip; + } + + public void setShipZip(String shipZip) { + this.shipZip = shipZip; + } + + public String getShipState() { + return shipState; + } + + public void setShipState(String shipState) { + this.shipState = shipState; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderItem.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderItem.java new file mode 100755 index 00000000..c1dc2cf0 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderItem.java @@ -0,0 +1,228 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Bean mapping for the ORDERITEM table. + */ +@Entity(name = "OrderItem") +@Table(name = "ORDERITEM", schema = "APP") +@NamedQueries({ @NamedQuery(name = "removeAllOrderItem", query = "delete from OrderItem") }) +public class OrderItem { + /** + * Composite Key class for Entity Bean: OrderItem + * + * Key consists of essentially two foreign key relations, but is mapped as foreign keys. + */ + @Embeddable + public static class PK implements java.io.Serializable { + static final long serialVersionUID = 3206093459760846163L; + @Column(name = "inventoryID") + public String inventoryID; + @Column(name = "ORDER_ORDERID") + public String order_orderID; + + public PK() { + Util.debug("OrderItem.PK()"); + } + + public PK(String inventoryID, String argOrder) { + Util.debug("OrderItem.PK() inventoryID=" + inventoryID + "="); + Util.debug("OrderItem.PK() orderID=" + argOrder + "="); + this.inventoryID = inventoryID; + this.order_orderID = argOrder; + } + + /** + * Returns true if both keys are equal. + */ + public boolean equals(java.lang.Object otherKey) { + if (otherKey instanceof PK) { + PK o = (PK) otherKey; + return ((this.inventoryID.equals(o.inventoryID)) && (this.order_orderID.equals(o.order_orderID))); + } + return false; + } + + /** + * Returns the hash code for the key. + */ + public int hashCode() { + Util.debug("OrderItem.PK.hashCode() inventoryID=" + inventoryID + "="); + Util.debug("OrderItem.PK.hashCode() orderID=" + order_orderID + "="); + + return (inventoryID.hashCode() + order_orderID.hashCode()); + } + } + + @SuppressWarnings("unused") + @EmbeddedId + private OrderItem.PK id; + private String name; + private String pkginfo; + private float price; + private float cost; + private int category; + private int quantity; + private String sellDate; + @Transient + private String inventoryId; + + @ManyToOne + @JoinColumn(name = "INVENTORYID", insertable = false, updatable = false) + private Inventory inventory; + @ManyToOne + @JoinColumn(name = "ORDER_ORDERID", insertable = false, updatable = false) + private Order order; + + public int getCategory() { + return category; + } + + public void setCategory(int category) { + this.category = category; + } + + public float getCost() { + return cost; + } + + public void setCost(float cost) { + this.cost = cost; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPkginfo() { + return pkginfo; + } + + public void setPkginfo(String pkginfo) { + this.pkginfo = pkginfo; + } + + public float getPrice() { + return price; + } + + public void setPrice(float price) { + this.price = price; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public String getSellDate() { + return sellDate; + } + + public void setSellDate(String sellDate) { + this.sellDate = sellDate; + } + + public OrderItem() { + } + + public OrderItem(Inventory inv) { + Util.debug("OrderItem(inv) - id = " + inv.getInventoryId()); + setInventoryId(inv.getInventoryId()); + inventory = inv; + name = inv.getName(); + pkginfo = inv.getPkginfo(); + price = inv.getPrice(); + cost = inv.getCost(); + category = inv.getCategory(); + } + + public OrderItem(Order order, String orderID, Inventory inv, java.lang.String name, java.lang.String pkginfo, + float price, float cost, int quantity, int category, java.lang.String sellDate) { + Util.debug("OrderItem(etc.)"); + inventory = inv; + setInventoryId(inv.getInventoryId()); + setName(name); + setPkginfo(pkginfo); + setPrice(price); + setCost(cost); + setQuantity(quantity); + setCategory(category); + setSellDate(sellDate); + setOrder(order); + id = new OrderItem.PK(inv.getInventoryId(), order.getOrderID()); + } + + /* + * updates the primary key field with the composite orderId+inventoryId + */ + public void updatePK() { + id = new OrderItem.PK(inventoryId, order.getOrderID()); + } + + public Inventory getInventory() { + return inventory; + } + + public void setInventory(Inventory inv) { + this.inventory = inv; + } + + public Order getOrder() { + return order; + } + + /** + * Sets the order for this item Also updates the sellDate + * + * @param order + */ + public void setOrder(Order order) { + this.order = order; + this.sellDate = order.getSellDate(); + } + + public String getInventoryId() { + return inventoryId; + } + + public void setInventoryId(String inventoryId) { + this.inventoryId = inventoryId; + } + +} \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderKey.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderKey.java new file mode 100755 index 00000000..f3993f3b --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/OrderKey.java @@ -0,0 +1,81 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import java.io.Serializable; + +/** + * The key class of the Order entity bean. + **/ +public class OrderKey implements Serializable { + + private static final long serialVersionUID = 7912030586849592135L; + + public String orderID; + + /** + * Constructs an OrderKey object. + */ + public OrderKey() { + } + + /** + * Constructs a newly allocated OrderKey object that represents the primitive long argument. + */ + public OrderKey(String orderID) { + this.orderID = orderID; + } + + /** + * Determines if the OrderKey object passed to the method matches this OrderKey object. + * + * @param obj + * java.lang.Object The OrderKey object to compare to this OrderKey object. + * @return boolean The pass object is either equal to this OrderKey object (true) or not. + */ + public boolean equals(Object obj) { + if (obj instanceof OrderKey) { + OrderKey otherKey = (OrderKey) obj; + return (((orderID.equals(otherKey.orderID)))); + } else + return false; + } + + /** + * Generates a hash code for this OrderKey object. + * + * @return int The hash code. + */ + public int hashCode() { + return (orderID.hashCode()); + } + + /** + * Get accessor for persistent attribute: orderID + */ + public java.lang.String getOrderID() { + return orderID; + } + + /** + * Set accessor for persistent attribute: orderID + */ + public void setOrderID(java.lang.String newOrderID) { + orderID = newOrderID; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Supplier.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Supplier.java new file mode 100755 index 00000000..1ec9f434 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/jpa/Supplier.java @@ -0,0 +1,135 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2004,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.jpa; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + +/** + * Bean mapping for the SUPPLIER table. + */ +@Entity(name = "Supplier") +@Table(name = "SUPPLIER", schema = "APP") +@NamedQueries({ @NamedQuery(name = "findAllSuppliers", query = "select s from Supplier s"), + @NamedQuery(name = "removeAllSupplier", query = "delete from Supplier") }) +public class Supplier { + @Id + private String supplierID; + private String name; + private String city; + private String usstate; + private String zip; + private String phone; + private String url; + private String street; + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getSupplierID() { + return supplierID; + } + + public void setSupplierID(String supplierID) { + this.supplierID = supplierID; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsstate() { + return usstate; + } + + public void setUsstate(String usstate) { + this.usstate = usstate; + } + + public String getZip() { + return zip; + } + + public void setZip(String zip) { + this.zip = zip; + } + + public Supplier() { + } + + public Supplier(String supplierID) { + setSupplierID(supplierID); + } + + /** + * @param supplierID + * @param name + * @param street + * @param city + * @param state + * @param zip + * @param phone + * @param url + */ + public Supplier(String supplierID, String name, String street, String city, String state, String zip, String phone, + String url) { + this.setSupplierID(supplierID); + this.setName(name); + this.setStreet(street); + this.setCity(city); + this.setUsstate(state); + this.setZip(zip); + this.setPhone(phone); + this.setUrl(url); + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/ListProperties.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/ListProperties.java new file mode 100644 index 00000000..6cca5c77 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/ListProperties.java @@ -0,0 +1,155 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2004,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.utils; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Hashtable; +import java.util.Properties; +import java.util.StringTokenizer; +import java.util.Vector; + + +/** + * @author aamortim + * + * To change the template for this generated type comment go to + * Window>Preferences>Java>Code Generation>Code and Comments + */ +/** + * Utility class. + */ +public class ListProperties extends Properties { + /** + * + */ + private static final long serialVersionUID = 1L; + private Hashtable> listProps = null; + /* Method load + * @param inStream + */ + + public void load(InputStream inStream) throws IOException { + try { + Util.debug("ListProperties.load - loading from stream "+inStream); + // Parse property file, remove comments, blank lines, and combine + // continued lines. + String propFile = ""; + BufferedReader inputLine = new BufferedReader(new InputStreamReader(inStream)); + String line = inputLine.readLine(); + boolean lineContinue = false; + while (line != null) { + Util.debug("ListProperties.load - Line read: " + line); + line = line.trim(); + String currLine = ""; + if (line.startsWith("#")) { + // Skipping comment + } else if (line.startsWith("!")) { + // Skipping comment + } else if (line.equals("")) { + // Skipping blank lines + } else { + if (!lineContinue) { + currLine = line; + } else { + // This is a continuation line. Add to previous line. + currLine += line; + } + // Must be a property line + if (line.endsWith("\\")) { + // Next line is continued from the current one. + lineContinue = true; + } else { + // The current line is completed. Parse the property. + propFile += currLine + "\n"; + currLine = ""; + lineContinue = false; + } + } + line = inputLine.readLine(); + } + // Load Properties + listProps = new Hashtable>(); + // Now parse the Properties to create an array + String[] props = readTokens(propFile, "\n"); + for (int index = 0; index < props.length; index++) { + Util.debug("ListProperties.load() - props[" + index + "] = " + props[index]); + // Parse the line to get the key,value pair + String[] val = readTokens(props[index], "="); + Util.debug("ListProperties.load() - val[0]: " + val[0] + " val[1]: " + val[1]); + if (!val[0].equals("")) { + if (this.containsKey(val[0])) { + // Previous key,value was already created. + // Need an array + Vector currList = (Vector) listProps.get(val[0]); + if ((currList == null) || currList.isEmpty()) { + currList = new Vector(); + String prevVal = this.getProperty(val[0]); + currList.addElement(prevVal); + } + currList.addElement(val[1]); + listProps.put(val[0], currList); + } + this.setProperty(val[0], val[1]); + } + } + } catch (Exception e) { + Util.debug("ListProperties.load(): Exception: " + e); + e.printStackTrace(); + } + } + /** + * Method readTokens. + * @param text + * @param token + * @return list + */ + public String[] readTokens(String text, String token) { + StringTokenizer parser = new StringTokenizer(text, token); + int numTokens = parser.countTokens(); + String[] list = new String[numTokens]; + for (int i = 0; i < numTokens; i++) { + list[i] = parser.nextToken(); + } + return list; + } + /** + * Method getProperties. + * @param name + * @return values + */ + public String[] getProperties(String name) { + String[] values = { "" }; + try { + String value = this.getProperty(name); + Util.debug("ListProperties.getProperties: property (" + name + ") -> " + value); + if (listProps.containsKey(name)) { + Vector list = (Vector) listProps.get(name); + values = new String[list.size()]; + for (int index = 0; index < list.size(); index++) { + values[index] = (String) list.elementAt(index); + } + } else { + values[0] = value; + } + } catch (Exception e) { + Util.debug("ListProperties.getProperties(): Exception: " + e); + } + return (values); + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/Util.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/Util.java new file mode 100644 index 00000000..7ec40402 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/utils/Util.java @@ -0,0 +1,311 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.utils; + +import java.io.FileNotFoundException; +import java.text.NumberFormat; +import java.util.StringTokenizer; + +import javax.faces.application.Application; +import javax.faces.application.ProjectStage; +import javax.faces.context.FacesContext; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +/** + * Utility class. + */ +public class Util { + /** Datasource name. */ + public static final String DS_NAME = "java:comp/env/jdbc/PlantsByWebSphereDataSource"; + // Constants for JSPs and HTMLs. + public static final String PAGE_ACCOUNT = "account.jsp"; + public static final String PAGE_CART = "cart.jsp"; + public static final String PAGE_CHECKOUTFINAL = "checkout_final.jsp"; + public static final String PAGE_HELP = "help.jsp"; + public static final String PAGE_LOGIN = "login.jsp"; + public static final String PAGE_ORDERDONE = "orderdone.jsp"; + public static final String PAGE_ORDERINFO = "orderinfo.jsp"; + public static final String PAGE_PRODUCT = "product.jsp"; + public static final String PAGE_PROMO = "promo.html"; + public static final String PAGE_REGISTER = "register.jsp"; + public static final String PAGE_SHOPPING = "shopping.jsp"; + public static final String PAGE_BACKADMIN = "backorderadmin.jsp"; + public static final String PAGE_SUPPLIERCFG = "supplierconfig.jsp"; + public static final String PAGE_ADMINHOME = "admin.html"; + public static final String PAGE_ADMINACTIONS = "adminactions.html"; + // Request and session attributes. + public static final String ATTR_ACTION = "action"; + public static final String ATTR_CART = "ShoppingCart"; +// public static final String ATTR_CART_CONTENTS = "CartContents"; + public static final String ATTR_CARTITEMS = "cartitems"; + public static final String ATTR_CATEGORY = "Category"; + public static final String ATTR_CHECKOUT = "CheckingOut"; + public static final String ATTR_CUSTOMER = "CustomerInfo"; + public static final String ATTR_EDITACCOUNTINFO = "EditAccountInfo"; + public static final String ATTR_INVITEM = "invitem"; + public static final String ATTR_INVITEMS = "invitems"; + public static final String ATTR_ORDERID = "OrderID"; + public static final String ATTR_ORDERINFO = "OrderInfo"; + public static final String ATTR_ORDERKEY = "OrderKey"; + public static final String ATTR_RESULTS = "results"; + public static final String ATTR_UPDATING = "updating"; + public static final int ATTR_SFTIMEOUT = 10; // if this is changed, updated session timeout + // in the PlantsByWebSphere web.xml + public static final String ATTR_SUPPLIER = "SupplierInfo"; + // Admin type actions + public static final String ATTR_ADMINTYPE = "admintype"; + public static final String ADMIN_BACKORDER = "backorder"; + public static final String ADMIN_SUPPLIERCFG = "supplierconfig"; + public static final String ADMIN_POPULATE = "populate"; + // Servlet action codes. + // Supplier Config actions + public static final String ACTION_GETSUPPLIER = "getsupplier"; + public static final String ACTION_UPDATESUPPLIER = "updatesupplier"; + // Backorder actions + public static final String ACTION_ORDERSTOCK = "orderstock"; + public static final String ACTION_UPDATESTOCK = "updatestock"; + public static final String ACTION_GETBACKORDERS = "getbackorders"; + public static final String ACTION_UPDATEQUANTITY = "updatequantity"; + public static final String ACTION_ORDERSTATUS = "orderstatus"; + public static final String ACTION_CANCEL = "cancel"; + public static final String STATUS_ORDERSTOCK = "Order Stock"; + public static final String STATUS_ORDEREDSTOCK = "Ordered Stock"; + public static final String STATUS_RECEIVEDSTOCK = "Received Stock"; + public static final String STATUS_ADDEDSTOCK = "Added Stock"; + public static final String DEFAULT_SUPPLIERID = "Supplier"; + private static InitialContext initCtx = null; + private static final String[] CATEGORY_STRINGS = { "Flowers", "Fruits & Vegetables", "Trees", "Accessories" }; + private static final String[] SHIPPING_METHOD_STRINGS = { "Standard Ground", "Second Day Air", "Next Day Air" }; + private static final String[] SHIPPING_METHOD_TIMES = { "( 3 to 6 business days )", "( 2 to 3 business days )", "( 1 to 2 business days )" }; + private static final float[] SHIPPING_METHOD_PRICES = { 4.99f, 8.99f, 12.99f }; + public static final String ZERO_14 = "00000000000000"; + /** + * Return the cached Initial Context. + * + * @return InitialContext, or null if a naming exception. + */ + static public InitialContext getInitialContext() { + try { + // Get InitialContext if it has not been gotten yet. + if (initCtx == null) { + // properties are in the system properties + initCtx = new InitialContext(); + } + } + // Naming Exception will cause a null return. + catch (NamingException e) {} + return initCtx; + } + + /** + * Get the displayable name of a category. + * @param index The int representation of a category. + * @return The category as a String (null, if an invalid index given). + */ + static public String getCategoryString(int index) { + if ((index >= 0) && (index < CATEGORY_STRINGS.length)) + return CATEGORY_STRINGS[index]; + else + return null; + } + /** + * Get the category strings in an array. + * + * @return The category strings in an array. + */ + static public String[] getCategoryStrings() { + return CATEGORY_STRINGS; + } + /** + * Get the shipping method. + * @param index The int representation of a shipping method. + * @return The shipping method (null, if an invalid index given). + */ + static public String getShippingMethod(int index) { + if ((index >= 0) && (index < SHIPPING_METHOD_STRINGS.length)) + return SHIPPING_METHOD_STRINGS[index]; + else + return null; + } + /** + * Get the shipping method price. + * @param index The int representation of a shipping method. + * @return The shipping method price (-1, if an invalid index given). + */ + static public float getShippingMethodPrice(int index) { + if ((index >= 0) && (index < SHIPPING_METHOD_PRICES.length)) + return SHIPPING_METHOD_PRICES[index]; + else + return -1; + } + /** + * Get the shipping method price. + * @param index The int representation of a shipping method. + * @return The shipping method time (null, if an invalid index given). + */ + static public String getShippingMethodTime(int index) { + if ((index >= 0) && (index < SHIPPING_METHOD_TIMES.length)) + return SHIPPING_METHOD_TIMES[index]; + else + return null; + } + /** + * Get the shipping method strings in an array. + * @return The shipping method strings in an array. + */ + static public String[] getShippingMethodStrings() { + return SHIPPING_METHOD_STRINGS; + } + /** + * Get the shipping method strings, including prices and times, in an array. + * @return The shipping method strings, including prices and times, in an array. + */ + static public String[] getFullShippingMethodStrings() { + String[] shippingMethods = new String[SHIPPING_METHOD_STRINGS.length]; + for (int i = 0; i < shippingMethods.length; i++) { + shippingMethods[i] = SHIPPING_METHOD_STRINGS[i] + " " + SHIPPING_METHOD_TIMES[i] + " " + NumberFormat.getCurrencyInstance(java.util.Locale.US).format(new Float(SHIPPING_METHOD_PRICES[i])); + } + return shippingMethods; + } + private static final String PBW_PROPERTIES = "pbw.properties"; + private static ListProperties PBW_Properties = null; + /** + * Method readProperties. + */ + public static void readProperties() throws FileNotFoundException { + if (PBW_Properties == null) { + // Try to read the properties file. + ListProperties prop = new ListProperties(); + try { + String PBW_Properties_File = PBW_PROPERTIES; + debug("Util.readProperties(): Loading PBW Properties from file: " + PBW_Properties_File); + prop.load(Util.class.getClassLoader().getResourceAsStream(PBW_Properties_File)); + } catch (Exception e) { + debug("Util.readProperties(): Exception: " + e); + // Reset properties to retry loading next time. + PBW_Properties = null; + e.printStackTrace(); + throw new FileNotFoundException(); + } + PBW_Properties = prop; + } + } + /** + * Method getProperty. + * @param name + * @return value + */ + public static String getProperty(String name) { + String value = ""; + try { + if (PBW_Properties == null) { + readProperties(); + } + value = PBW_Properties.getProperty(name); + } catch (Exception e) { + debug("Util.getProperty(): Exception: " + e); + } + return (value); + } + /** + * Method readTokens. + * @param text + * @param token + * @return list + */ + public static String[] readTokens(String text, String token) { + StringTokenizer parser = new StringTokenizer(text, token); + int numTokens = parser.countTokens(); + String[] list = new String[numTokens]; + for (int i = 0; i < numTokens; i++) { + list[i] = parser.nextToken(); + } + return list; + } + /** + * Method getProperties. + * @param name + * @return values + */ + public static String[] getProperties(String name) { + String[] values = { "" }; + try { + if (PBW_Properties == null) { + readProperties(); + } + values = PBW_Properties.getProperties(name); + debug("Util.getProperties: property (" + name + ") -> " + values.toString()); + //for (Enumeration e = PBW_Properties.propertyNames() ; e.hasMoreElements() ;) { + // debug((String)e.nextElement()); + //} + } catch (Exception e) { + debug("Util.getProperties(): Exception: " + e); + } + return (values); + } + static private boolean debug = false; + /** Set debug setting to on or off. + * @param val True or false. + */ + static final public void setDebug(boolean val) { + debug = val; + } + /** Is debug turned on? */ + static final public boolean debugOn() { + return debug; + } + /** + * Output RAS message. + * @param msg Message to be output. + */ + static final public void debug(String msg) { + FacesContext context = FacesContext.getCurrentInstance(); + if (context != null) { + Application app = context.getApplication(); + if (app != null) { + ProjectStage stage = app.getProjectStage(); + if (stage == ProjectStage.Development || stage == ProjectStage.UnitTest) { + setDebug(true); + } + } + if (debug) { + System.out.println(msg); + } + } + } + + /** + * Utilty functions for validating user input. + * validateString will return false if any of the invalid characters appear in the input string. + * + * In general, we do not want to allow special characters in user input, + * because this can open us to a XSS security vulnerability. + * For example, a user should not be allowed to enter javascript in an input field. + */ + static final char[] invalidCharList={'|','&',';','$','%','\'','\"','\\','<','>',','}; + + public static boolean validateString(String input){ + if (input==null) return true; + for (int i=0;i backOrders = backOrderStock.findBackOrders(); + ArrayList backOrderItems = new ArrayList(); + for (BackOrder bo : backOrders) { + BackOrderItem boi = new BackOrderItem(bo); + backOrderItems.add(boi); + } + Util.debug("AdminServlet.getBackOrders() - BackOrders found!"); + Iterator i = backOrderItems.iterator(); + while (i.hasNext()) { + BackOrderItem backOrderItem = (BackOrderItem) i.next(); + String backOrderID = backOrderItem.getBackOrderID(); + String inventoryID = backOrderItem.getInventory().getInventoryId(); + // Get the inventory quantity and name for the back order item + // information. + Inventory item = catalog.getItemInventory(inventoryID); + int quantity = item.getQuantity(); + backOrderItem.setInventoryQuantity(quantity); + String name = item.getName(); + backOrderItem.setName(name); + // Don't include backorders that have been completed. + if (!(backOrderItem.getStatus().equals(Util.STATUS_ADDEDSTOCK))) { + String invID = backOrderItem.getInventory().getInventoryId(); + String supplierOrderID = backOrderItem.getSupplierOrderID(); + String status = backOrderItem.getStatus(); + String lowDate = new Long(backOrderItem.getLowDate()).toString(); + String orderDate = new Long(backOrderItem.getOrderDate()).toString(); + Util.debug("AdminServlet.getBackOrders() - backOrderID = " + backOrderID); + Util.debug("AdminServlet.getBackOrders() - supplierOrderID = " + supplierOrderID); + Util.debug("AdminServlet.getBackOrders() - invID = " + invID); + Util.debug("AdminServlet.getBackOrders() - name = " + name); + Util.debug("AdminServlet.getBackOrders() - quantity = " + quantity); + Util.debug("AdminServlet.getBackOrders() - status = " + status); + Util.debug("AdminServlet.getBackOrders() - lowDate = " + lowDate); + Util.debug("AdminServlet.getBackOrders() - orderDate = " + orderDate); + } + } + session.setAttribute("backorderitems", backOrderItems); + } catch (Exception e) { + e.printStackTrace(); + Util.debug("AdminServlet.getBackOrders() - RemoteException: " + e); + } + } + + /** + * Method sendRedirect. + * + * @param resp + * @param page + * @throws ServletException + * @throws IOException + */ + private void sendRedirect(HttpServletResponse resp, String page) throws ServletException, IOException { + resp.sendRedirect(resp.encodeRedirectURL(page)); + } + + /** + * Method requestDispatch. + * + * @param ctx + * @param req + * @param resp + * @param page + * @throws ServletException + * @throws IOException + */ + /** + * Request dispatch + */ + private void requestDispatch(ServletContext ctx, + HttpServletRequest req, + HttpServletResponse resp, + String page) throws ServletException, IOException { + resp.setContentType("text/html"); + ctx.getRequestDispatcher(page).forward(req, resp); + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/BackOrderItem.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/BackOrderItem.java new file mode 100755 index 00000000..3cd15789 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/BackOrderItem.java @@ -0,0 +1,209 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import com.ibm.websphere.samples.pbw.jpa.BackOrder; +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * A class to hold a back order item's data. + */ +public class BackOrderItem implements java.io.Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + private String name; + private int inventoryQuantity; + private String backOrderID; // from BackOrder + private int quantity; // from BackOrder + private String status; // from BackOrder + private long lowDate; // from BackOrder + private long orderDate; // from BackOrder + private String supplierOrderID; // from BackOrder + private Inventory inventory; // from BackOrder + + /** + * @see java.lang.Object#Object() + */ + /** Default constructor. */ + public BackOrderItem() { + } + + /** + * Method BackOrderItem. + * + * @param backOrderID + * @param inventoryID + * @param name + * @param quantity + * @param status + */ + public BackOrderItem(String backOrderID, Inventory inventoryID, String name, int quantity, String status) { + this.backOrderID = backOrderID; + this.inventory = inventoryID; + this.name = name; + this.quantity = quantity; + this.status = status; + } + + /** + * Method BackOrderItem. + * + * @param backOrder + */ + public BackOrderItem(BackOrder backOrder) { + try { + this.backOrderID = backOrder.getBackOrderID(); + this.inventory = backOrder.getInventory(); + this.quantity = backOrder.getQuantity(); + this.status = backOrder.getStatus(); + this.lowDate = backOrder.getLowDate(); + this.orderDate = backOrder.getOrderDate(); + this.supplierOrderID = backOrder.getSupplierOrderID(); + } catch (Exception e) { + Util.debug("BackOrderItem - Exception: " + e); + } + } + + /** + * Method getBackOrderID. + * + * @return String + */ + public String getBackOrderID() { + return backOrderID; + } + + /** + * Method setBackOrderID. + * + * @param backOrderID + */ + public void setBackOrderID(String backOrderID) { + this.backOrderID = backOrderID; + } + + /** + * Method getSupplierOrderID. + * + * @return String + */ + public String getSupplierOrderID() { + return supplierOrderID; + } + + /** + * Method setSupplierOrderID. + * + * @param supplierOrderID + */ + public void setSupplierOrderID(String supplierOrderID) { + this.supplierOrderID = supplierOrderID; + } + + /** + * Method setQuantity. + * + * @param quantity + */ + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + /** + * Method getInventoryID. + * + * @return String + */ + public Inventory getInventory() { + return inventory; + } + + /** + * Method getName. + * + * @return String + */ + public String getName() { + return name; + } + + /** + * Method setName. + * + * @param name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Method getQuantity. + * + * @return int + */ + public int getQuantity() { + return quantity; + } + + /** + * Method getInventoryQuantity. + * + * @return int + */ + public int getInventoryQuantity() { + return inventoryQuantity; + } + + /** + * Method setInventoryQuantity. + * + * @param quantity + */ + public void setInventoryQuantity(int quantity) { + this.inventoryQuantity = quantity; + } + + /** + * Method getStatus. + * + * @return String + */ + public String getStatus() { + return status; + } + + /** + * Method getLowDate. + * + * @return long + */ + public long getLowDate() { + return lowDate; + } + + /** + * Method getOrderDate. + * + * @return long + */ + public long getOrderDate() { + return orderDate; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/HelpBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/HelpBean.java new file mode 100755 index 00000000..da35b978 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/HelpBean.java @@ -0,0 +1,86 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import java.io.Serializable; + +import javax.enterprise.context.Dependent; +import javax.inject.Inject; +import javax.inject.Named; + +import com.ibm.websphere.samples.pbw.bean.ResetDBBean; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * JSF action bean for the help page. + * + */ +@Named("help") +public class HelpBean implements Serializable { + + @Inject + private ResetDBBean rdb; + + private String dbDumpFile; + + private static final String ACTION_HELP = "help"; + private static final String ACTION_HOME = "promo"; + + public String performHelp() { + return ACTION_HELP; + } + + public String performDBReset() { + rdb.resetDB(); + return ACTION_HOME; + } + + /** + * @return the dbDumpFile + */ + public String getDbDumpFile() { + return dbDumpFile; + } + + /** + * @param dbDumpFile + * the dbDumpFile to set + */ + public void setDbDumpFile(String dbDumpFile) { + this.dbDumpFile = dbDumpFile; + } + + /** + * @return whether debug is on or not + */ + public boolean isDebug() { + return Util.debugOn(); + } + + /** + * Debugging is currently tied to the JavaServer Faces project stage. Any change here is likely + * to be automatically reset. + * + * @param debug + * Sets whether debug is on or not. + */ + public void setDebug(boolean debug) { + Util.setDebug(debug); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ImageServlet.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ImageServlet.java new file mode 100755 index 00000000..87ee3856 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ImageServlet.java @@ -0,0 +1,104 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import java.io.IOException; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.ibm.websphere.samples.pbw.bean.CatalogMgr; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Servlet to handle image actions. + */ +@Named(value = "image") +@WebServlet("/servlet/ImageServlet") +public class ImageServlet extends HttpServlet { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Inject + private CatalogMgr catalog; + + /** + * Servlet initialization. + */ + public void init(ServletConfig config) throws ServletException { + super.init(config); + } + + /** + * Process incoming HTTP GET requests + * + * @param request + * Object that encapsulates the request to the servlet + * @param response + * Object that encapsulates the response from the servlet + */ + public void doGet(javax.servlet.http.HttpServletRequest request, + javax.servlet.http.HttpServletResponse response) throws ServletException, IOException { + performTask(request, response); + } + + /** + * Process incoming HTTP POST requests + * + * @param request + * Object that encapsulates the request to the servlet + * @param response + * Object that encapsulates the response from the servlet + */ + public void doPost(javax.servlet.http.HttpServletRequest request, + javax.servlet.http.HttpServletResponse response) throws ServletException, IOException { + performTask(request, response); + } + + /** + * Main service method for ImageServlet + * + * @param request + * Object that encapsulates the request to the servlet + * @param response + * Object that encapsulates the response from the servlet + */ + private void performTask(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + String action = null; + + action = req.getParameter("action"); + Util.debug("action=" + action); + + if (action.equals("getimage")) { + String inventoryID = req.getParameter("inventoryID"); + + byte[] buf = catalog.getItemImageBytes(inventoryID); + if (buf != null) { + resp.setContentType("image/jpeg"); + resp.getOutputStream().write(buf); + } + } + } +} \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/LoginInfo.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/LoginInfo.java new file mode 100755 index 00000000..41d6a0ae --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/LoginInfo.java @@ -0,0 +1,72 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +/** + * A JSF backing bean used to store information for the login web page. It is accessed via the + * account bean. + * + */ +public class LoginInfo { + private String checkPassword; + + @Pattern(regexp = "[a-zA-Z0-9_-]+@[a-zA-Z0-9.-]+") + private String email; + private String message; + + @Size(min = 6, max = 10, message = "Password must be between 6 and 10 characters.") + private String password; + + public LoginInfo() { + } + + public String getCheckPassword() { + return this.checkPassword; + } + + public String getEmail() { + return this.email; + } + + public String getMessage() { + return this.message; + } + + public String getPassword() { + return this.password; + } + + public void setCheckPassword(String checkPassword) { + this.checkPassword = checkPassword; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setMessage(String message) { + this.message = message; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/MailAction.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/MailAction.java new file mode 100755 index 00000000..44457ac1 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/MailAction.java @@ -0,0 +1,64 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import javax.inject.Inject; +import javax.inject.Named; + +import com.ibm.websphere.samples.pbw.bean.MailerAppException; +import com.ibm.websphere.samples.pbw.bean.MailerBean; +import com.ibm.websphere.samples.pbw.jpa.Customer; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * This class sends the email confirmation message. + */ +@Named("mailaction") +public class MailAction implements java.io.Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Inject + private MailerBean mailer; + + /** Public constructor */ + public MailAction() { + } + + /** + * Send the email order confirmation message. + * + * @param customer + * The customer information. + * @param orderKey + * The order number. + */ + public final void sendConfirmationMessage(Customer customer, + String orderKey) { + try { + System.out.println("mailer=" + mailer); + mailer.createAndSendMail(customer, orderKey); + } + // The MailerAppException will be ignored since mail may not be configured. + catch (MailerAppException e) { + Util.debug("Mailer threw exception, mail may not be configured. Exception:" + e); + } + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/OrderInfo.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/OrderInfo.java new file mode 100755 index 00000000..e069b745 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/OrderInfo.java @@ -0,0 +1,519 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import java.util.Calendar; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import com.ibm.websphere.samples.pbw.jpa.Order; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * A class to hold an order's data. + */ +public class OrderInfo implements java.io.Serializable { + private static final long serialVersionUID = 1L; + private String orderID; + @NotNull + @Size(min = 1, message = "Name for billing must include at least one letter.") + private String billName; + @NotNull + @Size(min = 1, message = "Billing address must include at least one letter.") + private String billAddr1; + private String billAddr2; + @NotNull + @Size(min = 1, message = "Billing city must include at least one letter.") + private String billCity; + @NotNull + @Size(min = 1, message = "Billing state must include at least one letter.") + private String billState; + + @Pattern(regexp = "\\d{5}", message = "Billing zip code does not have 5 digits.") + private String billZip; + + @Pattern(regexp = "\\d{3}-\\d{3}-\\d{4}", message = "Billing phone number does not match xxx-xxx-xxxx.") + private String billPhone; + @NotNull + @Size(min = 1, message = "Name for shipping must include at least one letter.") + private String shipName; + @NotNull + @Size(min = 1, message = "Shipping address must include at least one letter.") + private String shipAddr1; + private String shipAddr2; + @NotNull + @Size(min = 1, message = "Shipping city must include at least one letter.") + private String shipCity; + @NotNull + @Size(min = 1, message = "Shipping state must include at least one letter.") + private String shipState; + + @Pattern(regexp = "[0-9][0-9][0-9][0-9][0-9]", message = "Shipping zip code does not have 5 digits.") + private String shipZip; + + @Pattern(regexp = "\\d{3}-\\d{3}-\\d{4}", message = "Shipping phone number does not match xxx-xxx-xxxx.") + private String shipPhone; + private int shippingMethod; + @NotNull + @Size(min = 1, message = "Card holder name must include at least one letter.") + private String cardholderName; + private String cardName; + + @Pattern(regexp = "\\d{4} \\d{4} \\d{4} \\d{4}", message = "Credit card numbers must be entered as XXXX XXXX XXXX XXXX.") + private String cardNum; + private String cardExpMonth; + private String cardExpYear; + private String[] cardExpYears; + private boolean shipisbill = false; + + /** + * Constructor to create an OrderInfo by passing each field. + */ + public OrderInfo(String billName, String billAddr1, String billAddr2, String billCity, String billState, + String billZip, String billPhone, String shipName, String shipAddr1, String shipAddr2, String shipCity, + String shipState, String shipZip, String shipPhone, int shippingMethod, String orderID) { + this.orderID = orderID; + this.billName = billName; + this.billAddr1 = billAddr1; + this.billAddr2 = billAddr2; + this.billCity = billCity; + this.billState = billState; + this.billZip = billZip; + this.billPhone = billPhone; + this.shipName = shipName; + this.shipAddr1 = shipAddr1; + this.shipAddr2 = shipAddr2; + this.shipCity = shipCity; + this.shipState = shipState; + this.shipZip = shipZip; + this.shipPhone = shipPhone; + this.shippingMethod = shippingMethod; + initLists(); + cardholderName = ""; + cardNum = ""; + } + + /** + * Constructor to create an OrderInfo using an Order. + * + * @param order + */ + public OrderInfo(Order order) { + orderID = order.getOrderID(); + billName = order.getBillName(); + billAddr1 = order.getBillAddr1(); + billAddr2 = order.getBillAddr2(); + billCity = order.getBillCity(); + billState = order.getBillState(); + billZip = order.getBillZip(); + billPhone = order.getBillPhone(); + shipName = order.getShipName(); + shipAddr1 = order.getShipAddr1(); + shipAddr2 = order.getShipAddr2(); + shipCity = order.getShipCity(); + shipState = order.getShipState(); + shipZip = order.getShipZip(); + shipPhone = order.getShipPhone(); + shippingMethod = order.getShippingMethod(); + } + + /** + * Get the shipping method name. + */ + public String getShippingMethodName() { + return getShippingMethods()[shippingMethod]; + } + + /** + * Set the shipping method by name + */ + public void setShippingMethodName(String name) { + String[] methodNames = Util.getShippingMethodStrings(); + for (int i = 0; i < methodNames.length; i++) { + if (methodNames[i].equals(name)) + shippingMethod = i; + } + } + + /** + * Get shipping methods that are possible. + * + * @return String[] of method names + */ + public String[] getShippingMethods() { + return Util.getFullShippingMethodStrings(); + } + + public int getShippingMethodCount() { + return Util.getShippingMethodStrings().length; + } + + private void initLists() { + int i = Calendar.getInstance().get(1); + cardExpYears = new String[5]; + for (int j = 0; j < 5; j++) + cardExpYears[j] = (new Integer(i + j)).toString(); + } + + /** + * @return the orderID + */ + public String getID() { + return orderID; + } + + /** + * @param orderID + * the orderID to set + */ + public void setID(String orderID) { + this.orderID = orderID; + } + + /** + * @return the billName + */ + public String getBillName() { + return billName; + } + + /** + * @param billName + * the billName to set + */ + public void setBillName(String billName) { + this.billName = billName; + } + + /** + * @return the billAddr1 + */ + public String getBillAddr1() { + return billAddr1; + } + + /** + * @param billAddr1 + * the billAddr1 to set + */ + public void setBillAddr1(String billAddr1) { + this.billAddr1 = billAddr1; + } + + /** + * @return the billAddr2 + */ + public String getBillAddr2() { + return billAddr2; + } + + /** + * @param billAddr2 + * the billAddr2 to set + */ + public void setBillAddr2(String billAddr2) { + this.billAddr2 = billAddr2; + } + + /** + * @return the billCity + */ + public String getBillCity() { + return billCity; + } + + /** + * @param billCity + * the billCity to set + */ + public void setBillCity(String billCity) { + this.billCity = billCity; + } + + /** + * @return the billState + */ + public String getBillState() { + return billState; + } + + /** + * @param billState + * the billState to set + */ + public void setBillState(String billState) { + this.billState = billState; + } + + /** + * @return the billZip + */ + public String getBillZip() { + return billZip; + } + + /** + * @param billZip + * the billZip to set + */ + public void setBillZip(String billZip) { + this.billZip = billZip; + } + + /** + * @return the billPhone + */ + public String getBillPhone() { + return billPhone; + } + + /** + * @param billPhone + * the billPhone to set + */ + public void setBillPhone(String billPhone) { + this.billPhone = billPhone; + } + + /** + * @return the shipName + */ + public String getShipName() { + return shipName; + } + + /** + * @param shipName + * the shipName to set + */ + public void setShipName(String shipName) { + this.shipName = shipName; + } + + /** + * @return the shipAddr1 + */ + public String getShipAddr1() { + return shipAddr1; + } + + /** + * @param shipAddr1 + * the shipAddr1 to set + */ + public void setShipAddr1(String shipAddr1) { + this.shipAddr1 = shipAddr1; + } + + /** + * @return the shipAddr2 + */ + public String getShipAddr2() { + return shipAddr2; + } + + /** + * @param shipAddr2 + * the shipAddr2 to set + */ + public void setShipAddr2(String shipAddr2) { + this.shipAddr2 = shipAddr2; + } + + /** + * @return the shipCity + */ + public String getShipCity() { + return shipCity; + } + + /** + * @param shipCity + * the shipCity to set + */ + public void setShipCity(String shipCity) { + this.shipCity = shipCity; + } + + /** + * @return the shipState + */ + public String getShipState() { + return shipState; + } + + /** + * @param shipState + * the shipState to set + */ + public void setShipState(String shipState) { + this.shipState = shipState; + } + + /** + * @return the shipZip + */ + public String getShipZip() { + return shipZip; + } + + /** + * @param shipZip + * the shipZip to set + */ + public void setShipZip(String shipZip) { + this.shipZip = shipZip; + } + + /** + * @return the shipPhone + */ + public String getShipPhone() { + return shipPhone; + } + + /** + * @param shipPhone + * the shipPhone to set + */ + public void setShipPhone(String shipPhone) { + this.shipPhone = shipPhone; + } + + /** + * @return the shippingMethod + */ + public int getShippingMethod() { + return shippingMethod; + } + + /** + * @param shippingMethod + * the shippingMethod to set + */ + public void setShippingMethod(int shippingMethod) { + this.shippingMethod = shippingMethod; + } + + /** + * @return the cardholderName + */ + public String getCardholderName() { + return cardholderName; + } + + /** + * @param cardholderName + * the cardholderName to set + */ + public void setCardholderName(String cardholderName) { + this.cardholderName = cardholderName; + } + + /** + * @return the cardName + */ + public String getCardName() { + return cardName; + } + + /** + * @param cardName + * the cardName to set + */ + public void setCardName(String cardName) { + this.cardName = cardName; + } + + /** + * @return the cardNum + */ + public String getCardNum() { + return cardNum; + } + + /** + * @param cardNum + * the cardNum to set + */ + public void setCardNum(String cardNum) { + this.cardNum = cardNum; + } + + /** + * @return the cardExpMonth + */ + public String getCardExpMonth() { + return cardExpMonth; + } + + /** + * @param cardExpMonth + * the cardExpMonth to set + */ + public void setCardExpMonth(String cardExpMonth) { + this.cardExpMonth = cardExpMonth; + } + + /** + * @return the cardExpYear + */ + public String getCardExpYear() { + return cardExpYear; + } + + /** + * @param cardExpYear + * the cardExpYear to set + */ + public void setCardExpYear(String cardExpYear) { + this.cardExpYear = cardExpYear; + } + + /** + * @return the cardExpYears + */ + public String[] getCardExpYears() { + return cardExpYears; + } + + /** + * @param cardExpYears + * the cardExpYears to set + */ + public void setCardExpYears(String[] cardExpYears) { + this.cardExpYears = cardExpYears; + } + + /** + * @return the shipisbill + */ + public boolean isShipisbill() { + return shipisbill; + } + + /** + * @param shipisbill + * the shipisbill to set + */ + public void setShipisbill(boolean shipisbill) { + this.shipisbill = shipisbill; + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/Populate.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/Populate.java new file mode 100755 index 00000000..93b14a92 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/Populate.java @@ -0,0 +1,303 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2004,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.URL; +import java.util.Vector; + +import com.ibm.websphere.samples.pbw.bean.BackOrderMgr; +import com.ibm.websphere.samples.pbw.bean.CatalogMgr; +import com.ibm.websphere.samples.pbw.bean.CustomerMgr; +import com.ibm.websphere.samples.pbw.bean.ResetDBBean; +import com.ibm.websphere.samples.pbw.bean.ShoppingCartBean; +import com.ibm.websphere.samples.pbw.bean.SuppliersBean; +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * A basic POJO class for resetting the database. + */ +public class Populate { + + private ResetDBBean resetDB; + + private CatalogMgr catalog; + + private CustomerMgr login; + + private ShoppingCartBean cart; + + private BackOrderMgr backOrderStock; + + private SuppliersBean suppliers; + + /** + * + */ + public Populate() { + } + + public Populate(ResetDBBean resetDB, CatalogMgr c, CustomerMgr l, BackOrderMgr b, SuppliersBean s) { + this.resetDB = resetDB; + this.catalog = c; + this.login = l; + this.backOrderStock = b; + this.suppliers = s; + } + + /** + * @param itemID + * @param fileName + * @param catalog + * @throws FileNotFoundException + * @throws IOException + */ + public static void addImage(String itemID, + String fileName, + CatalogMgr catalog) throws FileNotFoundException, IOException { + URL url = Thread.currentThread().getContextClassLoader().getResource("resources/images/" + fileName); + Util.debug("URL: " + url); + fileName = url.getPath(); + Util.debug("Fully-qualified Filename: " + fileName); + File imgFile = new File(fileName); + // Open the input file as a stream of bytes + FileInputStream fis = new FileInputStream(imgFile); + DataInputStream dis = new DataInputStream(fis); + int dataSize = dis.available(); + byte[] data = new byte[dataSize]; + dis.readFully(data); + catalog.setItemImageBytes(itemID, data); + } + + /** + * + */ + public void doPopulate() { + try { + resetDB.deleteAll(); + } catch (Exception e) { + Util.debug("Populate:doPopulate() - Exception deleting data in database: " + e); + e.printStackTrace(); + } + /** + * Populate INVENTORY table with text + */ + Util.debug("Populating INVENTORY table with text..."); + try { + String[] values = Util.getProperties("inventory"); + for (int index = 0; index < values.length; index++) { + Util.debug("Found INVENTORY property values: " + values[index]); + String[] fields = Util.readTokens(values[index], "|"); + String id = fields[0]; + String name = fields[1]; + String heading = fields[2]; + String descr = fields[3]; + String pkginfo = fields[4]; + String image = fields[5]; + float price = new Float(fields[6]).floatValue(); + float cost = new Float(fields[7]).floatValue(); + int quantity = new Integer(fields[8]).intValue(); + int category = new Integer(fields[9]).intValue(); + String notes = fields[10]; + boolean isPublic = new Boolean(fields[11]).booleanValue(); + Util.debug("Populating INVENTORY with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + Util.debug(fields[10]); + Util.debug(fields[11]); + Inventory storeItem = new Inventory(id, name, heading, descr, pkginfo, image, price, cost, quantity, + category, notes, isPublic); + catalog.addItem(storeItem); + addImage(id, image, catalog); + } + Util.debug("INVENTORY table populated with text..."); + } catch (Exception e) { + Util.debug("Unable to populate INVENTORY table with text data: " + e); + } + /** + * Populate CUSTOMER table with text + */ + Util.debug("Populating CUSTOMER table with default values..."); + try { + String[] values = Util.getProperties("customer"); + Util.debug("Found CUSTOMER properties: " + values[0]); + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String customerID = fields[0]; + String password = fields[1]; + String firstName = fields[2]; + String lastName = fields[3]; + String addr1 = fields[4]; + String addr2 = fields[5]; + String addrCity = fields[6]; + String addrState = fields[7]; + String addrZip = fields[8]; + String phone = fields[9]; + Util.debug("Populating CUSTOMER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + login.createCustomer(customerID, password, firstName, lastName, addr1, addr2, addrCity, addrState, addrZip, phone); + } + } catch (Exception e) { + Util.debug("Unable to populate CUSTOMER table with text data: " + e); + } + /** + * Populate ORDER table with text + */ + Util.debug("Populating ORDER table with default values..."); + try { + String[] values = Util.getProperties("order"); + Util.debug("Found ORDER properties: " + values[0]); + if (values[0] != null && values.length > 0) { + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + if (fields != null && fields.length >= 21) { + String customerID = fields[0]; + String billName = fields[1]; + String billAddr1 = fields[2]; + String billAddr2 = fields[3]; + String billCity = fields[4]; + String billState = fields[5]; + String billZip = fields[6]; + String billPhone = fields[7]; + String shipName = fields[8]; + String shipAddr1 = fields[9]; + String shipAddr2 = fields[10]; + String shipCity = fields[11]; + String shipState = fields[12]; + String shipZip = fields[13]; + String shipPhone = fields[14]; + int shippingMethod = Integer.parseInt(fields[15]); + String creditCard = fields[16]; + String ccNum = fields[17]; + String ccExpireMonth = fields[18]; + String ccExpireYear = fields[19]; + String cardHolder = fields[20]; + Vector items = new Vector(); + Util.debug("Populating ORDER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + Util.debug(fields[8]); + Util.debug(fields[9]); + Util.debug(fields[10]); + Util.debug(fields[11]); + Util.debug(fields[12]); + Util.debug(fields[13]); + Util.debug(fields[14]); + Util.debug(fields[15]); + Util.debug(fields[16]); + Util.debug(fields[17]); + Util.debug(fields[18]); + Util.debug(fields[19]); + Util.debug(fields[20]); + cart.createOrder(customerID, billName, billAddr1, billAddr2, billCity, billState, billZip, billPhone, shipName, shipAddr1, shipAddr2, shipCity, shipState, shipZip, shipPhone, creditCard, ccNum, ccExpireMonth, ccExpireYear, cardHolder, shippingMethod, items); + } else { + Util.debug("Property does not contain enough fields: " + values[index]); + Util.debug("Fields found were: " + fields); + } + } + } + // stmt.executeUpdate(" INSERT INTO ORDERITEM(INVENTORYID, NAME, PKGINFO, PRICE, COST, + // CATEGORY, QUANTITY, SELLDATE, ORDER_ORDERID) VALUES ('A0001', 'Bulb Digger', + // 'Assembled', 12.0, 5.0, 3, 900, '01054835419625', '1')"); + } catch (Exception e) { + Util.debug("Unable to populate ORDERITEM table with text data: " + e); + e.printStackTrace(); + } + /** + * Populate BACKORDER table with text + */ + Util.debug("Populating BACKORDER table with default values..."); + try { + String[] values = Util.getProperties("backorder"); + Util.debug("Found BACKORDER properties: " + values[0]); + // Inserting backorders + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String inventoryID = fields[0]; + int amountToOrder = new Integer(fields[1]).intValue(); + int maximumItems = new Integer(fields[2]).intValue(); + Util.debug("Populating BACKORDER with following values: "); + Util.debug(inventoryID); + Util.debug("amountToOrder -> " + amountToOrder); + Util.debug("maximumItems -> " + maximumItems); + backOrderStock.createBackOrder(inventoryID, amountToOrder, maximumItems); + } + } catch (Exception e) { + Util.debug("Unable to populate BACKORDER table with text data: " + e); + } + /** + * Populate SUPPLIER table with text + */ + Util.debug("Populating SUPPLIER table with default values..."); + try { + String[] values = Util.getProperties("supplier"); + Util.debug("Found SUPPLIER properties: " + values[0]); + // Inserting Suppliers + for (int index = 0; index < values.length; index++) { + String[] fields = Util.readTokens(values[index], "|"); + String supplierID = fields[0]; + String name = fields[1]; + String address = fields[2]; + String city = fields[3]; + String state = fields[4]; + String zip = fields[5]; + String phone = fields[6]; + String url = fields[7]; + Util.debug("Populating SUPPLIER with following values: "); + Util.debug(fields[0]); + Util.debug(fields[1]); + Util.debug(fields[2]); + Util.debug(fields[3]); + Util.debug(fields[4]); + Util.debug(fields[5]); + Util.debug(fields[6]); + Util.debug(fields[7]); + suppliers.createSupplier(supplierID, name, address, city, state, zip, phone, url); + } + } catch (Exception e) { + Util.debug("Unable to populate SUPPLIER table with text data: " + e); + } + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ProductBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ProductBean.java new file mode 100755 index 00000000..854c2d06 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ProductBean.java @@ -0,0 +1,82 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import java.io.Serializable; +import java.text.NumberFormat; +import java.util.Locale; +import java.util.Objects; + +import com.ibm.websphere.samples.pbw.jpa.Inventory; +import com.ibm.websphere.samples.pbw.utils.Util; + +/** + * Provides backing bean support for the product web page. Accessed via the shopping bean. + * + */ +public class ProductBean implements Serializable { + private static final long serialVersionUID = 1L; + private Inventory inventory; + private int quantity; + + protected ProductBean(Inventory inventory) { + Objects.requireNonNull(inventory, "Inventory cannot be null"); + this.inventory = inventory; + this.quantity = 1; + } + + public String getCategoryName() { + return Util.getCategoryString(this.inventory.getCategory()); + } + + public Inventory getInventory() { + return this.inventory; + } + + public String getMenuString() { + String categoryString = getCategoryName(); + + if (categoryString.equals("Flowers")) { + return "banner:menu1"; + } + + else if (categoryString.equals("Fruits & Vegetables")) { + return "banner:menu2"; + } + + else if (categoryString.equals("Trees")) { + return "banner:menu3"; + } + + else { + return "banner:menu4"; + } + } + + public String getPrice() { + return NumberFormat.getCurrencyInstance(Locale.US).format(new Float(this.inventory.getPrice())); + } + + public int getQuantity() { + return this.quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingBean.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingBean.java new file mode 100755 index 00000000..c1abb847 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingBean.java @@ -0,0 +1,181 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// +package com.ibm.websphere.samples.pbw.war; + +import java.io.Serializable; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; + +import javax.enterprise.context.SessionScoped; +import javax.faces.context.ExternalContext; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; + +import com.ibm.websphere.samples.pbw.bean.CatalogMgr; +import com.ibm.websphere.samples.pbw.bean.ShoppingCartBean; +import com.ibm.websphere.samples.pbw.jpa.Inventory; + +/** + * A combination JSF action bean and backing bean for the shopping web page. + * + */ +@Named(value = "shopping") +@SessionScoped +public class ShoppingBean implements Serializable { + private static final long serialVersionUID = 1L; + private static final String ACTION_CART = "cart"; + private static final String ACTION_PRODUCT = "product"; + private static final String ACTION_SHOPPING = "shopping"; + + // keep an independent list of items so we can add pricing methods + private ArrayList cartItems; + + @Inject + private CatalogMgr catalog; + + private ProductBean product; + private LinkedList products; + private float shippingCost; + + @Inject + private ShoppingCartBean shoppingCart; + + public String performAddToCart() { + Inventory item = new Inventory(this.product.getInventory()); + + item.setQuantity(this.product.getQuantity()); + + shoppingCart.addItem(item); + + return performCart(); + } + + public String performCart() { + cartItems = wrapInventoryItems(shoppingCart.getItems()); + + return ShoppingBean.ACTION_CART; + } + + public String performProductDetail() { + FacesContext facesContext = FacesContext.getCurrentInstance(); + ExternalContext externalContext = facesContext.getExternalContext(); + Map requestParams = externalContext.getRequestParameterMap(); + + this.product = new ProductBean(this.catalog.getItemInventory(requestParams.get("itemID"))); + + return ShoppingBean.ACTION_PRODUCT; + } + + public String performRecalculate() { + + shoppingCart.removeZeroQuantityItems(); + + this.cartItems = wrapInventoryItems(shoppingCart.getItems()); + + return performCart(); + } + + public String performShopping() { + int category = 0; + FacesContext facesContext = FacesContext.getCurrentInstance(); + ExternalContext externalContext = facesContext.getExternalContext(); + Vector inventories; + Map requestParams = externalContext.getRequestParameterMap(); + + try { + category = Integer.parseInt(requestParams.get("category")); + } + + catch (Throwable e) { + if (this.products != null) { + // No category specified, so just use the last one. + + return ShoppingBean.ACTION_SHOPPING; + } + } + + inventories = this.catalog.getItemsByCategory(category); + + this.products = new LinkedList(); + + // Have to convert all the inventory objects into product beans. + + for (Object obj : inventories) { + Inventory inventory = (Inventory) obj; + + if (inventory.isPublic()) { + this.products.add(new ProductBean(inventory)); + } + } + + return ShoppingBean.ACTION_SHOPPING; + } + + public Collection getCartItems() { + return this.cartItems; + } + + public ProductBean getProduct() { + return this.product; + } + + public Collection getProducts() { + return this.products; + } + + public String getShippingCostString() { + return NumberFormat.getCurrencyInstance(Locale.US).format(this.shippingCost); + } + + /** + * @return the shippingCost + */ + public float getShippingCost() { + return shippingCost; + } + + public void setShippingCost(float shippingCost) { + this.shippingCost = shippingCost; + + } + + public float getTotalCost() { + return shoppingCart.getSubtotalCost() + this.shippingCost; + } + + public String getTotalCostString() { + return NumberFormat.getCurrencyInstance(Locale.US).format(getTotalCost()); + } + + public ShoppingCartBean getCart() { + return shoppingCart; + } + + private ArrayList wrapInventoryItems(Collection invItems) { + ArrayList shoppingList = new ArrayList(); + for (Inventory i : invItems) { + shoppingList.add(new ShoppingItem(i)); + } + return shoppingList; + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingItem.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingItem.java new file mode 100755 index 00000000..a860e811 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ShoppingItem.java @@ -0,0 +1,374 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import java.io.Serializable; + +import javax.validation.constraints.Min; + +import com.ibm.websphere.samples.pbw.jpa.BackOrder; +import com.ibm.websphere.samples.pbw.jpa.Inventory; + +/** + * ShoppingItem wraps the JPA Inventory entity class to provide additional methods needed by the web + * app. + */ +public class ShoppingItem implements Cloneable, Serializable { + + private static final long serialVersionUID = 1L; + private Inventory item; + + public ShoppingItem() { + + } + + public ShoppingItem(Inventory i) { + item = i; + } + + public ShoppingItem(String key, String name, String heading, String desc, String pkginfo, String image, float price, + float cost, int quantity, int category, String notes, boolean isPublic) { + item = new Inventory(key, name, heading, desc, pkginfo, image, price, cost, quantity, category, notes, + isPublic); + } + + /** + * Subtotal price calculates a cost based on price and quantity. + */ + public float getSubtotalPrice() { + return getPrice() * getQuantity(); + } + + /** + * @param o + * @return boolean true if object equals this + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + return item.equals(o); + } + + /** + * @return int hashcode for this object + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return item.hashCode(); + } + + /** + * @return String String representation of this object + * @see java.lang.Object#toString() + */ + public String toString() { + return item.toString(); + } + + /** + * @param quantity + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#increaseInventory(int) + */ + public void increaseInventory(int quantity) { + item.increaseInventory(quantity); + } + + /** + * @return int category enum int value + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getCategory() + */ + public int getCategory() { + return item.getCategory(); + } + + /** + * @param category + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setCategory(int) + */ + public void setCategory(int category) { + item.setCategory(category); + } + + /** + * @return float cost of the item + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getCost() + */ + public float getCost() { + return item.getCost(); + } + + /** + * @param cost + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setCost(float) + */ + public void setCost(float cost) { + item.setCost(cost); + } + + /** + * @return String description of the item + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getDescription() + */ + public String getDescription() { + return item.getDescription(); + } + + /** + * @param description + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setDescription(java.lang.String) + */ + public void setDescription(String description) { + item.setDescription(description); + } + + /** + * @return String item heading + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getHeading() + */ + public String getHeading() { + return item.getHeading(); + } + + /** + * @param heading + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setHeading(java.lang.String) + */ + public void setHeading(String heading) { + item.setHeading(heading); + } + + /** + * @return String image URI + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getImage() + */ + public String getImage() { + return item.getImage(); + } + + /** + * @param image + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setImage(java.lang.String) + */ + public void setImage(String image) { + item.setImage(image); + } + + /** + * @return String name of the item + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getName() + */ + public String getName() { + return item.getName(); + } + + /** + * @param name + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setName(java.lang.String) + */ + public void setName(String name) { + item.setName(name); + } + + /** + * @return String item notes + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getNotes() + */ + public String getNotes() { + return item.getNotes(); + } + + /** + * @param notes + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setNotes(java.lang.String) + */ + public void setNotes(String notes) { + item.setNotes(notes); + } + + /** + * @return String package information + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getPkginfo() + */ + public String getPkginfo() { + return item.getPkginfo(); + } + + /** + * @param pkginfo + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setPkginfo(java.lang.String) + */ + public void setPkginfo(String pkginfo) { + item.setPkginfo(pkginfo); + } + + /** + * @return float Price of the item + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getPrice() + */ + public float getPrice() { + return item.getPrice(); + } + + /** + * @param price + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setPrice(float) + */ + public void setPrice(float price) { + item.setPrice(price); + } + + /** + * Property accessor for quantity of items ordered. Quantity may not be less than zero. Bean + * Validation will ensure this is true. + * + * @return int quantity of items + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getQuantity() + */ + @Min(value = 0, message = "Quantity must be a number greater than or equal to zero.") + public int getQuantity() { + return item.getQuantity(); + } + + /** + * @param quantity + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setQuantity(int) + */ + public void setQuantity(int quantity) { + item.setQuantity(quantity); + } + + /** + * @return int maximum threshold + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getMaxThreshold() + */ + public int getMaxThreshold() { + return item.getMaxThreshold(); + } + + /** + * @param maxThreshold + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setMaxThreshold(int) + */ + public void setMaxThreshold(int maxThreshold) { + item.setMaxThreshold(maxThreshold); + } + + /** + * @return int minimum threshold + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getMinThreshold() + */ + public int getMinThreshold() { + return item.getMinThreshold(); + } + + /** + * @param minThreshold + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setMinThreshold(int) + */ + public void setMinThreshold(int minThreshold) { + item.setMinThreshold(minThreshold); + } + + /** + * @return String item ID in the inventory + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getInventoryId() + */ + public String getInventoryId() { + return item.getInventoryId(); + } + + /** + * @param id + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setInventoryId(java.lang.String) + */ + public void setInventoryId(String id) { + item.setInventoryId(id); + } + + /** + * @return String item ID + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getID() + */ + public String getID() { + return item.getID(); + } + + /** + * @param id + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setID(java.lang.String) + */ + public void setID(String id) { + item.setID(id); + } + + /** + * @return boolean true if this is a public item + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#isPublic() + */ + public boolean isPublic() { + return item.isPublic(); + } + + /** + * @param isPublic + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setIsPublic(boolean) + */ + public void setIsPublic(boolean isPublic) { + item.setIsPublic(isPublic); + } + + /** + * @param isPublic + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setPrivacy(boolean) + */ + public void setPrivacy(boolean isPublic) { + item.setPrivacy(isPublic); + } + + /** + * @return byte[] item image as a byte array + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getImgbytes() + */ + public byte[] getImgbytes() { + return item.getImgbytes(); + } + + /** + * @param imgbytes + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setImgbytes(byte[]) + */ + public void setImgbytes(byte[] imgbytes) { + item.setImgbytes(imgbytes); + } + + /** + * @return BackOrder item is on back order + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#getBackOrder() + */ + public BackOrder getBackOrder() { + return item.getBackOrder(); + } + + /** + * @param backOrder + * @see com.ibm.websphere.samples.pbw.jpa.Inventory#setBackOrder(com.ibm.websphere.samples.pbw.jpa.BackOrder) + */ + public void setBackOrder(BackOrder backOrder) { + item.setBackOrder(backOrder); + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatePasswords.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatePasswords.java new file mode 100755 index 00000000..c62f6a8d --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatePasswords.java @@ -0,0 +1,49 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import javax.faces.component.UIComponent; +import javax.faces.component.UIInput; +import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; +import javax.faces.validator.Validator; +import javax.faces.validator.ValidatorException; + +/** + * A JSF validator class, not implemented in Bean Validation since validation is only required + * during GUI interaction. + */ +@FacesValidator(value = "validatePasswords") +public class ValidatePasswords implements Validator { + + @Override + public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException { + UIInput otherComponent; + String otherID = (String) component.getAttributes().get("otherPasswordID"); + String otherStr; + String str = (String) value; + + otherComponent = (UIInput) context.getViewRoot().findComponent(otherID); + otherStr = (String) otherComponent.getValue(); + + if (!otherStr.equals(str)) { + ValidatorUtils.addErrorMessage(context, "Passwords do not match."); + } + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatorUtils.java b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatorUtils.java new file mode 100755 index 00000000..ca2ad3f2 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/java/com/ibm/websphere/samples/pbw/war/ValidatorUtils.java @@ -0,0 +1,43 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2003,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +package com.ibm.websphere.samples.pbw.war; + +import javax.faces.application.FacesMessage; +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; +import javax.faces.validator.ValidatorException; + +/** + * Simple helper class for JSF validators to handle error messages. + * + */ +public class ValidatorUtils { + protected static void addErrorMessage(FacesContext context, String message) { + FacesMessage facesMessage = new FacesMessage(); + facesMessage.setDetail(message); + facesMessage.setSummary(message); + facesMessage.setSeverity(FacesMessage.SEVERITY_ERROR); + throw new ValidatorException(facesMessage); + } + + protected static void addErrorMessage(FacesContext context, UIComponent component) { + String errorMessage = (String) component.getAttributes().get("errorMessage"); + + addErrorMessage(context, errorMessage); + } +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/liberty/config/server.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/liberty/config/server.xml new file mode 100644 index 00000000..7288548d --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/liberty/config/server.xml @@ -0,0 +1,39 @@ + + + + javaee-7.0 + localConnector-1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/META-INF/persistence.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/META-INF/persistence.xml new file mode 100755 index 00000000..3269f800 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/META-INF/persistence.xml @@ -0,0 +1,14 @@ + + + jdbc/PlantsByWebSphereDataSource + jdbc/PlantsByWebSphereDataSourceNONJTA + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/pbw.properties b/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/pbw.properties new file mode 100644 index 00000000..1a2858e9 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/resources/pbw.properties @@ -0,0 +1,58 @@ +# +# Row Values for Inventory Table +# +inventory=F0001|African Orchid|Rare Delicate Beauty|African orchids are some of the most endangered and rare kinds of orchids grown today. This variety is medium yellow with varigated salmon and pink insides. Height: 18 to 28 inches.|per plant|flower_african_orchid.jpg|250.00|145.00|100|0|NOTES and stuff|true +inventory=F0002|Baby Breath|Ethereal White Elegance|(Gypsophila muralis). Small, delicate Baby Breath flowers create clouds of accents in floral arrangements or beautiful lacy designs when used alone. Can be used fresh or dried. Height: 12 to 18 inches.|2 plants|flower_bbreath.jpg|6.00|2.00|100|0|NOTES and stuff|true +inventory=F0003|Black-eyed Susan|Radiant, like the Sun|(Rudbeckia hirta). The Black-Eyed Susan was made the official Maryland flower in 1918. Typically they grow wild -- and bloom between May and August -- but you can purchase them as a permanent addition to your own garden. Height: 2 to 3 feet.|2 plants|flower_black-eyed_susan.jpg|9.00|2.00|100|0|NOTES and stuff|true +inventory=F0004|Coleus|Colorful Accent|(Coleus blumei). An attractive foliage plant, the Coleus is especially suited for containers and underplantings. While it can tolerate the sun, the color of leaves is enhanced in partial to full shade. Height: 12 inches to 36 inches.|4 plants|flower_coleus.jpg|8.00|3.00|100|0|NOTES and stuff|true +inventory=F0005|Yellow Shasta Daisy|Charming Simple Beauty|(Bellis perenis). Oversized blossoms in bright yellow with a very long bloom period. For extra decoration, cut the stems and place in food coloring and water to make vibrantly colored cut flowers. Height: 1 to 3 feet.|2 plants|flower_daisies.jpg|16.00|2.50|100|0|NOTES and stuff|true +inventory=F0006|Perennial Foxglove|Showy Thimble-like Blooms|(Digitalis). Foxglove grows best in shade and works well as a tall, showy flower that lights up a dark garden area. The individual flowers are sized and shaped like thimbles. Height: 2 to 3 feet.|3 plants|flower_foxglove.jpg|12.00|2.75|100|0|NOTES and stuff|true +inventory=F0007|Geranium|Red and Flowery|(Geranium sanguineum). This bright red version of the Bloody Cranesbill Geranium has small, bright green foliage that adds dimension and sets off the vibrant colored flowers. Assembled. Height: 8 inches.|per plant|flower_geranium.jpg|8.00|2.30|100|0|NOTES and stuff|true +inventory=F0008|Goodnight Moon Iris|Fluorescent Bloomer|Iris provides lovely cut flowers which brighten rainy spring days. When the Iris has stopped blossoming, cut off dead blossoms and dead bloom stalks, but do not cut back the leaves until they begin to turn brown in the Fall.|5 bulbs|flower_goodnight_moon_iris.jpg|7.50|3.60|100|0|NOTES and stuff|true +inventory=F0009|Impatiens|Tangerine Dream|(Impatiens walleriana). Vibrant tangerine-orange flowers coordinate nicely with green foliage. Impatiens is a great annual for beds, borders, containers and hanging baskets. Grow in full sun to partial shade. Height: 15 to 20 inches.|2 plants|flower_impatiens.jpg|9.95|1.25|100|0|NOTES and stuff|true +inventory=F0010|Lily|Purple Summer Glory|(Hemerocallis fulva) Magnificent flowers up to 3 inches or more across. Blooms start June through August, depending on variety, and have a subtle fragrance. Tolerates dry soil but it is wise to water deeply during periods of dry weather.|4 bulbs|flower_lily.jpg|6.50|3.25|100|0|NOTES and stuff|true +inventory=F0011|Pansy|Autumn Mix|(Viola tricolor). Reminiscent of the colors of fall. Our Pansies will bloom from fall to early winter, and again in the spring! They prefer part shade to full sun. Height 6 to 8 inches.|1 pkt. (25 seeds)|flower_pansies.jpg|2.00|1.25|100|0|NOTES and stuff|true +inventory=F0012|Petunia|Striped Brightness|(Petunia x hybrida). Striking, large magenta flowers with contrasting white trumpet stripes. Excellent for borders, window boxes, planters and bouquets. Petunias do best in full sun but will tolerate light shade. Height: 1 foot.|1 pkt. (50 seeds)|flower_petunias.jpg|3.00|1.25|100|0|NOTES and stuff|true +inventory=F0013|Primrose|Means: I Cannot Live Without You|(Primula). Large, fragrant blooms in wide-eyed spring like yellow. Plants thrive despite heat and drought and require good drainage. Height: 12 inches.|6 plants|flower_primrose.jpg|10.00|4.75|100|0|NOTES and stuff|true +inventory=F0014|Red Poinsettia|Seasonal Beauty|(Euphorbia pulcherrima). Lush red flowers float atop deep green leaves. They were first developed in Mexico and need warm temperatures and full sun. Height: 2 to 3 feet.|per plant|flower_red_poinsettia.jpg|11.00|4.50|100|0|NOTES and stuff|true +inventory=F0015|Red Rose|Always in Bloom|(Rosa Floribunda). Created in France (1956), this rose continually produces boldly colored, medium-sized red blooms. Intensely fragrant. Includes thorns and songs about lost love. Height: 10 - 12 feet.|per vine|flower_red_rose.jpg|32.00|15.00|100|0|NOTES and stuff|true +inventory=F0016|Sparkler Celosia|Brilliant Flames of Red Fire|(Celosia plumosa). Excellent for cutting, these Sparkler Celosia have brilliant 6 inch plumes. They are a perfect companion for full-sun garden beds or in fresh or dried bouquets. Height: 2 to 2.5 feet.|4 plants|flower_sparkler_celosia.jpg|7.00|3.25|100|0|NOTES and stuff|true +inventory=F0017|Tulip|Mixed Dutch Delight|(Tulipa). Out famous tulip bulbs are supplied by one of the finest Dutch bulb growers. Mixed colors resonate on even the cloudiest of days. These bulbs are of the highest quality and are guaranteed. Height: 10 to 12 inches.|10 bulbs|flower_tulips.jpg|17.00|9.00|100|0|NOTES and stuff|true +inventory=F0018|White Poinsettia|Seasonal Simplicity|(Euphorbia pulcherrima). A rich color of deep green leaves support large bright white blossoms. Poinsettias were first developed in Mexico and need full sun. Height: 2 to 3 feet.|per plant|flower_white_poinsettia.jpg|14.00|5.50|100|0|NOTES and stuff|true +inventory=F0019|White Rose|A Classic Beauty|(Rosa Floribunda). Classic, white buds open into double blooms of palest pink to white on this rose created in 1888 France. Thornless. Height: 4 to 5 feet.|per vine|flower_white_rose.jpg|37.00|17.00|100|0|NOTES and stuff|true +inventory=F0020|Zinnia|You cut more, they bloom more!|(Zinnia elegans). Zinnias add bold, vibrant color to gardens. They are heat loving and prefer full-sun. Perfect for beds and cut floral arrangements. They even attract butterflies! Height: 12 to 18 inches.|12 plants|flower_zinnia.jpg|7.95|3.95|100|0|NOTES and stuff|true +inventory=A0001|Bulb Digger|Pick The Right Tool For The Right Job|Simplifies digging holes for poles, posts, and many other jobs. Tempered steel even breaks through rock. Long, coated 54 inch hardwood handle.|Assembled|accessories_bulbdigger.jpg|12.00|5.00|100|3|NOTES and stuff|true +inventory=A0002|Birdfeeder|Birds of a Feather Feed Together|Hexagon shaped bird feeder stores food upright which allows more birds to feed and gives you the best view! Natural wood base supports clear plastic lenses on all 5 sides. Ready to be hung or mounted on a pole (not included).|Pole not included|accessories_birdfeeder.jpg|16.00|7.00|100|3|NOTES and stuff|true +inventory=A0003|Birdhouse|Ideal for Nesting Birds|Wooden birdhouse perfect for nesting birds and their companions. Made of naturally weather resistant pine with a sloped roof. Mounting hardware and instructions included. Height: 18 inches. Width: 10 inches.|Assembled|accessories_birdhouse.jpg|12.00|6.00|100|3|NOTES and stuff|true +inventory=A0004|Finch Food|Attracts Fabulous Finches|Bird feed especially formulated for finches, as well as other small birds. No seeds are wasted; birds will like them all.|20 lb. bag|accessories_finchfood.jpg|6.50|2.00|100|3|NOTES and stuff|true +inventory=A0005|Grass Rake|Put the Kids to Work|Welded bow rake is heat treated for strength. Long, coated 54 inch hardwood handle. Use it to level and break up clumps of soil, remove debris, and spread topsoil or compost. 5 year limited warranty.|Assembled|accessories_grassrake.jpg|6.00|2.50|100|3|NOTES and stuff|true +inventory=A0006|Leaf Rake|The Ultimate Backscratcher|Wooden polyurethene coated handle adjusts is 32 inches long. Comfortable grip. Fully heat treated head and chip resistant carbon dioxide coating make this rake last for years.|Assembled|accessories_leafrake.jpg|10.00|4.50|100|3|NOTES and stuff|true +inventory=A0007|Shovel|Dig it, Man!|Open back tempered steel blade attached to sturdy hardwood handle with 6 inch lead. Uses include: planting shrubs, trees, and general digging or cutting through sod or soil. Handle Length: 46 inches|Assembled|accessories_shovel.jpg|7.00|3.00|100|3|NOTES and stuff|true +inventory=A0008|Gloves|If The Gloves Fit, You Must Plant It|One size fits all. Each carefully sewn left glove comes with an accompanying right glove. Comes in pack of 3, with colors red, green, and blue.|3 pairs per pack|accessories_gloves.jpg|4.50|1.00|100|3|NOTES and stuff|true +inventory=A0009|Hand Rake|A Real Humdinger|Sometimes you have to work on your hands and knees. This tool is great for raking, digging, whatever. Handle is cushioned with rubber.|Assembled|accessories_handrake.jpg|4.50|1.50|100|3|NOTES and stuff|true +inventory=A0010|Large Pot|Large and, well, just Large|Large ceramic pot perfect for bigger plants that need to be moved in during frosts. Diameter of 18 inches - holds 5 gallon plants.|N/A|accessories_pot.jpg|10.00|3.00|100|3|NOTES and stuff|true +inventory=A0011|Wheelbarrow|Just like Grandpa used to have!|Shiny red wheelbarrow with epoxy coated steel bin and wooden handles. Tire is solid with thick treads that grip rough, wet surfaces. Large capacity - 3 Cu.Ft. capacity, 150 Lb. maximum load|Assembled|accessories_wheelbarrow.jpg|29.00|12.00|100|3|NOTES and stuff|true +inventory=T0001|Ash|Full and Leafy like a Lollipop|Large, round, summer shade leads to yellow leaves that burst through dreary Fall days! Excellent for yards. Mature height: up to 20 feet.|10 gallon seedling|trees_ash.jpg|50.00|20.00|100|2|NOTES and stuff|true +inventory=T0002|Aspen|Tall, Slender Grace|White barked Aspens are particularly beautiful during white winters. Close your eyes and imagine a light breeze sailing over the trunk and the crinkling of the colliding leaves. Mature height: up to 28 feet.|10 gallon seedling|trees_aspen.jpg|53.00|21.00|100|2|NOTES and stuff|true +inventory=T0003|Bonsai|Tabletop Fun|Bonsais are great miniature replicas of your favorite yard tree. They can be indoors or out -- and their size makes them perfect for tabletop decoration.|0.5 gallon mature tree|trees_bonsai.jpg|30.00|12.00|100|2|NOTES and stuff|true +inventory=T0004|Crabapple|Short but beautiful|These trees light up Springtime with pink, fragrant flowers that change into crabapples. Perfect for Maryland residents. Mature height: up to 20 feet.|10 gallon seedling|trees_crab.jpg|57.00|19.00|100|2|NOTES and stuff|true +inventory=T0005|Maple|Traditional Shade Producer|Famous for their syrup, you will be able to tap into your own endless supply in just a few years. Not suitable for diabetics. Mature height: up to 24 feet.|10 gallon seedling|trees_maple.jpg|45.00|22.00|100|2|NOTES and stuff|true +inventory=V0001|Cabbage|Crispy|Crispy green cabbage will poke through summer gardens about 3-4 weeks after springtime planting of seedlings. An excellent source of Vitamin A and D.|1 pkt. (100 seeds)|veggies_cabbage.jpg|2.00|.70|100|1|NOTES and stuff|true +inventory=V0002|Ornamental Gourd|Gourd-geous!|OrNAMEntal gourds are a staple for Autumn flowerbeds, door decorations, floral arrangements and tabletop centerpieces. Grow your own this year to give to your neighbors and family.|1 pkt. (100 seeds)|veggies_gourds.jpg|1.50|.70|100|1|NOTES and stuff|true +inventory=V0003|Grapes|Be Your Own Winemaker|Join others who are fermenting their own small, personal batches of wine! These vines were developed in France and their grapes make a fruity, medium white wine or a fruity Beaujolais when pressed with the skins.|1 vine|veggies_grapes.jpg|49.00|20.50|100|1|NOTES and stuff|true +inventory=V0004|Onion|Fresh and Tasty from your Garden|Pure white onions are sweetest when grown at home and left in the ground until picking. Tissues not included.|4 bulbs|veggies_onion.jpg|9.00|4.75|100|1|NOTES and stuff|true +inventory=V0005|Pineapple|Tropical Delight|Pineapples can be grown at home with this frost-bearing breed. Yields 4 - 5 fruits annually, more in warmer climates. Fertilize with organic compost regularly for best results. Be careful of maurading neighbors.|8 gallon potted plant|veggies_pineapple.jpg|87.00|34.50|100|1|NOTES and stuff|true +inventory=V0006|Strawberries|Sweet Berry Scrumptiousness|Our brand is known for producing plump, sweet strawberries by the mid-June bucketful. Now you can grow them easily, with relatively little care, due to our patented version. Dental floss not included.|1 pkt. (50 seeds)|veggies_strawberries.jpg|3.50|1.50|100|1|NOTES and stuff|true +inventory=V0007|Watermelon|Seedless Summer |Plant our seeds indoors in late winter and transfer outside after threat of frost recedes; our seeds will produce huge, round, ripe melons by mid-June. Guaranteed not to contain active Acidophilous cultures.|1 pkt. (100 seeds)|veggies_watermelon.jpg|2.00|.50|50|1|NOTES and stuff|true +# +# Row Values for Idgenerator Table +# +idgenerator=ORDER|1 +idgenerator=BACKORDER|2 +# +# Row Values for Customer Table +# +customer=plants@plantsbywebsphere.ibm.com|plants|David|Grover|123 Main Street|Apt. C|Raleigh|NC|27604|919-555-1234 +# +# Row Values for Supplier Table +supplier=Supplier|Greenhouse By WebSphere|4205 Miami Blvd.|Durham|NC|27709|919-555-1212|http://localhost:9080/OrderProcessorEJB/services/FrontGate?wsdl \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/PlantTemplate.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/PlantTemplate.xhtml new file mode 100755 index 00000000..d3b63c0b --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/PlantTemplate.xhtml @@ -0,0 +1,139 @@ + + + + + + + + + ${title} + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/beans.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/beans.xml new file mode 100755 index 00000000..d8a87307 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/beans.xml @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/faces-config.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/faces-config.xml new file mode 100755 index 00000000..9c84443c --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,19 @@ + + + + + pc_Help + pagecode.Help + request + + + + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-ejb-jar-bnd.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-ejb-jar-bnd.xml new file mode 100755 index 00000000..b790daa7 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-ejb-jar-bnd.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-bnd.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-bnd.xml new file mode 100755 index 00000000..d191ed33 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-bnd.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-ext.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-ext.xml new file mode 100755 index 00000000..a214742c --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/ibm-web-ext.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/web.xml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/web.xml new file mode 100755 index 00000000..1d486eea --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,69 @@ + + + PlantsByWebSphere + + javax.faces.PROJECT_STAGE + + Development + + + javax.faces.VALIDATE_EMPTY_FIELDS + false + + + index.html + + + FacesServlet + javax.faces.webapp.FacesServlet + + + javax.faces.application.ViewExpiredException + /viewExpired.xhtml + + + /error.jsp + + + FacesServlet + *.jsf + + + + SampAdmin + Sample Admin + /adminactions.html + /adminbanner.html + /backorderadmin.jsp + /servlet/AdminServlet + /supplierconfig.jsp + GET + PUT + HEAD + TRACE + POST + DELETE + OPTIONS + + + Samples Administrator + SampAdmin + + + NONE + + + + BASIC + Default + + + Samples Administrator + SampAdmin + + + 10 + + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/account.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/account.xhtml new file mode 100755 index 00000000..47d3da47 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/account.xhtml @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + +
+

+ + > + +

+
+ + + + + + + + + + + + + + + +

Account + Update

+ Enter the information below to update your account. This + information will not be shared without your permission. With + your permission we will only share your name and email address + with our trusted business partners.

+

+

+ Required fields are denoted with a red asterisk ( + + ).

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact + Information
   

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+
+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/admin.html b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/admin.html new file mode 100755 index 00000000..fda304e2 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/admin.html @@ -0,0 +1,39 @@ + + + + + + + + +Plants by WebSphere Administration + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminactions.html b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminactions.html new file mode 100755 index 00000000..3a3aa673 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminactions.html @@ -0,0 +1,74 @@ + + + + + + + + + + +Plants by WebSphere Administration + + + + + + + + + + + + + + + + + + + + +
Manage + BackOrders - View backorder inventory, order from suppliers, add + new stock to inventory.
Supplier + Configuration - Configure the Supplier.
+
+ + + + + +
Powered by WebSphere + +
+ + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminbanner.html b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminbanner.html new file mode 100755 index 00000000..5467bec3 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/adminbanner.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + +
Plants by WebSphere Administration
+ + + + + + +
  HOME  :  ADMIN HOME  :  + HELP  
+ + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/applycss.js b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/applycss.js new file mode 100755 index 00000000..49132df1 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/applycss.js @@ -0,0 +1,27 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +var i = navigator.appVersion.indexOf('MSIE 6'); + +if ((navigator.appName == "Microsoft Internet Explorer") + && (parseInt(navigator.appVersion) >= 4)) { + document + .write(''); +} else { + document + .write(''); +} \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/backorderadmin.jsp b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/backorderadmin.jsp new file mode 100755 index 00000000..f8475f90 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/backorderadmin.jsp @@ -0,0 +1,526 @@ + + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +backorderadmin.jsp + + + + + + + + + <%@page + import="com.ibm.websphere.samples.pbw.war.BackOrderItem,com.ibm.websphere.samples.pbw.jpa.Inventory,com.ibm.websphere.samples.pbw.utils.Util,java.text.SimpleDateFormat,java.util.*" + session="true" isThreadSafe="true" isErrorPage="false"%> + + <% + Collection backOrderItems = (Collection) session.getAttribute("backorderitems"); + %> + + + + + + + + + + +
+

+ Admin + Home +

+
+ + + + + + + + + + + + + + <% + if (backOrderItems != null) { + %> + + + + + + + + + + +
+

BackOrder Administration

+
<% + String results; + results = (String) request.getAttribute(Util.ATTR_RESULTS); + if (results != null) + out.print(results); + %> +
+

Here are the inventory items that have been back + ordered. +

+ +
+


+
+
+ Back Order Items
+
+

+ The Back Order Items list shows the inventory items + that may be ordered from a supplier. Select one or more + ordered items and click the Order Stock to send an + order to the supplier. The QUANTITY TO ORDER may be + changed before the order is submitted. +


+ + + + + + + + + + + + + + <% + Util.debug("BackOrders Found in backorderadmin.jsp"); + Iterator i = backOrderItems.iterator(); + while (i.hasNext()) { + BackOrderItem backOrderItem = (BackOrderItem) i.next(); + String status = backOrderItem.getStatus(); + if (status.equals(Util.STATUS_ORDERSTOCK)) { + String backOrderID = backOrderItem.getBackOrderID(); + String invID = backOrderItem.getInventory().getInventoryId(); + String name = backOrderItem.getName(); + int quantity = backOrderItem.getQuantity(); + int inventoryQuantity = backOrderItem.getInventoryQuantity(); + + Date lowDateRaw = new Date(backOrderItem.getLowDate()); + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a zzz"); + String lowDate = formatter.format(lowDateRaw); + %> + + + + + + + + + + + + + + + + + + + + + <% + } // if (status.equals(Utils.STATUS_ORDERSTOCK()) + } // End while (i.hasNext() + } // if (backOrderItems != null) + else { + Util.debug("NO BackOrders Found in backorderadmin.jsp"); + } + %> + + + + + + + + +
BACK + ORDER #ITEM + #ITEM + DESCRIPTIONQUANTITY TO ORDERCURRENT INVENTORY + QUANTITYLOW INVENTORY DATE
+ +
+

<%=backOrderID%>

+
+

<%=invID%>

+
+

<%=name%>

+
+

<%=inventoryQuantity%>

+
+

<%=lowDate%>

+
+ +
+
+
+ Ordered Items

+
+

+ The Ordered Items list shows the inventory items that + have already been ordered from a supplier but have not been + received yet. Select one or more ordered items and click the Check + Status to check the status from the supplier. +

+ + + + + + + + + + + + + + + <% + if (backOrderItems != null) { + Util.debug("BackOrders Found in backorderadmin.jsp"); + Iterator i = backOrderItems.iterator(); + while (i.hasNext()) { + BackOrderItem backOrderItem = (BackOrderItem) i.next(); + String status = backOrderItem.getStatus(); + if (status.equals(Util.STATUS_ORDEREDSTOCK)) { + String backOrderID = backOrderItem.getBackOrderID(); + String supplierOrderID = backOrderItem.getSupplierOrderID(); + String invID = backOrderItem.getInventory().getInventoryId(); + String name = backOrderItem.getName(); + int quantity = backOrderItem.getQuantity(); + int inventoryQuantity = backOrderItem.getInventoryQuantity(); + + Date lowDateRaw = new Date(backOrderItem.getLowDate()); + Date orderedDateRaw = new Date(backOrderItem.getOrderDate()); + + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a zzz"); + String lowDate = formatter.format(lowDateRaw); + String orderedDate = formatter.format(orderedDateRaw); + %> + + + + + + + + + + + + <% + } // if (status.equals(Utils.STATUS_ORDEREDSTOCK()) + } // End while (i.hasNext() + } // if (backOrderItems != null) + else { + Util.debug("NO BackOrders Found in backorderadmin.jsp"); + } + %> + + + + + + + +
BACK + ORDER #SUPPLIER + ORDER #ITEM + #ITEM + DESCRIPTIONQUANTITY ORDEREDCURRENT INVENTORY + QUANTITYLOW INVENTORY DATEORDERED DATE
+

<%=backOrderID%>

+
+

<%=supplierOrderID%>

+
+

<%=invID%>

+
+

<%=name%>

+
+

<%=quantity%>

+
+

<%=inventoryQuantity%>

+
+

<%=lowDate%>

+
+

<%=orderedDate%>

+
+ + +
+
+
+ Received Items

+
+

+ The Received Items list shows the inventory items that + have been received from a supplier but have not been added to + the inventory. Select one or more ordered items and click the + Update Stock to add the inventory received from the + supplier. +

+ + + + + + + + + + + + + + + <% + if (backOrderItems != null) { + Util.debug("BackOrders Found in backorderadmin.jsp"); + Iterator i = backOrderItems.iterator(); + while (i.hasNext()) { + BackOrderItem backOrderItem = (BackOrderItem) i.next(); + String status = backOrderItem.getStatus(); + if (status.equals(Util.STATUS_RECEIVEDSTOCK)) { + String backOrderID = backOrderItem.getBackOrderID(); + String supplierOrderID = backOrderItem.getSupplierOrderID(); + String invID = backOrderItem.getInventory().getInventoryId(); + String name = backOrderItem.getName(); + int quantity = backOrderItem.getQuantity(); + int inventoryQuantity = backOrderItem.getInventoryQuantity(); + + Date lowDateRaw = new Date(backOrderItem.getLowDate()); + Date orderedDateRaw = new Date(backOrderItem.getOrderDate()); + + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a zzz"); + String lowDate = formatter.format(lowDateRaw); + String orderedDate = formatter.format(orderedDateRaw); + %> + + + + + + + + + + + + + <% + } // if (status.equals(Util.STATUS_RECEIVEDSTOCK)) + } // End while (i.hasNext() + } // if (backOrderItems != null) + else { + Util.debug("NO BackOrders Found in backorderadmin.jsp"); + } + %> + + + + + + + + +
BACK + ORDER #SUPPLIER + ORDER #ITEM + #ITEM + DESCRIPTIONQUANTITY RECEIVEDCURRENT INVENTORY + QUANTITYLOW INVENTORY DATEORDERED DATE
+

<%=backOrderID%>

+
+

<%=supplierOrderID%>

+
+

<%=invID%>

+
+

<%=name%>

+
+

<%=quantity%>

+
+

<%=inventoryQuantity%>

+
+

<%=lowDate%>

+
+

<%=orderedDate%>

+
+ +
+

+
+ + + + + + +
+

+
+

+ + + + + +
Powered by WebSphere + +
+ + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/cart.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/cart.xhtml new file mode 100755 index 00000000..4694d0be --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/cart.xhtml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + +

Here are the items you have selected. To recalculate your + total after changing the quantity of an item, select the + 'Recalculate' button. To remove an item from your cart, enter "0" + as the quantity. Select 'Checkout Now' to begin the checkout + process.

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +

+ Order Subtotal:   + + + +

+
+ + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+
+ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/checkout_final.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/checkout_final.xhtml new file mode 100755 index 00000000..72516243 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/checkout_final.xhtml @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + +
+

+ + > + + > + +

+
+ + + + + + + + + + + + +
Review + Your Order

+ Review your order below and select 'Submit Order' at the + bottom to place your order. You can also add more items to + your order by selecting 'Continue Shopping'.
+
+

+ + + + + + + + + + + +
Order Information
+ + + + + + + +
ORDER TOTAL
+

+ + + + +

+
+
+ + + + + + + +
SHIPPING ADDRESS
+

+ +
+ +
+ +
+ +
+ +
+

+
+
+ + + + + + + +
BILLING ADDRESS
+

+ +
+ +
+ +
+ +
+ +
+

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Order Details
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Order + Subtotal:

+

+ + + +

+
+

+ +

+
+

+ + + +

+

+ Order Total: +

+

+ + + + +

+
 
+ + + + + +
+ + + +
+
+
+
+
+ + + + +
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/collectionform.js b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/collectionform.js new file mode 100755 index 00000000..f5811db5 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/collectionform.js @@ -0,0 +1,188 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2001,2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +var isNav4, isIE; +var coll = ""; +var styleObj = ""; +if (parseInt(navigator.appVersion) >= 4) { + if (navigator.appName == "Netscape") { + isNav4 = true; + } else { + isIE = true; + coll = "all."; + styleObj = ".style"; + } +} + +function refresh() { + if (refreshTree.value == "true") + parent.navigation_tree.location.reload(true); +} + +var numchecks = 0; +var allchecked = false; +var multiall = new Array(); +function updateCheckAll(theForm, chkname) { + var temp; + var alltemp = 0; + var formlen = theForm.length; + if (chkname != null) { + var allchkname = chkname.substring(0, chkname.indexOf("CheckBox")); + allchkname = "allchecked" + allchkname; + } + for (var i = 0; i < formlen; i++) { + var theitem = theForm.elements[i].name; + var ischeck = theitem.indexOf("selectedObjectIds", 0) + 1; /* simple string search on checkbox consistent name, you change it to deleteID or whatever */ + var allcurcheck = theitem.indexOf(allchkname, 0) + 1; + if (allcurcheck > 0) { + alltemp = i; + } + if (chkname == null) { + + if (ischeck > 0) { + if (allchecked != true) { + theForm.elements[i].checked = true; + temp = true; + } else { + theForm.elements[i].checked = false; + temp = false; + + } + } + + var appitem = theForm.elements[i].name; + var appcheck = appitem.indexOf("checkBoxes", 0) + 1; + if ((appitem == "checkBoxes1") || (appitem == "checkBoxes2")) { + appcheck = 0; + } + + if (appcheck > 0) { + if (allchecked != true) { + theForm.elements[i].checked = true; + temp = true; + + } else { + theForm.elements[i].checked = false; + temp = false; + + } + } + + } else { + + var curitem = theForm.elements[i].name; + //var curcheck = curitem.indexOf(chkname[0].name,0) + 1; + + var curcheck = curitem.indexOf(chkname, 0) + 1; + + if (curcheck > 0) { + if ((allchecked != true) && (multiall[allchkname] != true)) { + theForm.elements[i].checked = true; + temp = true; + + } else { + theForm.elements[i].checked = false; + temp = false; + + } + } + + } + + } + + if (temp == true) { + if (chkname == null) { + allchecked = true; + theForm.allchecked.checked = true; + } else { + multiall[allchkname] = true; + theForm.elements[alltemp].checked = true; + } + } else { + if (chkname == null) { + allchecked = false; + theForm.allchecked.checked = false; + } else { + multiall[allchkname] = false; + theForm.elements[alltemp].checked = false; + } + } + +} + +function checkChecks(theForm, chkname) { + var checkednum = 0; + var uncheckednum = 0; + var formlen = theForm.length; + + for (var i = 0; i < formlen; i++) { + var theitem = theForm.elements[i].name; + var ischeck = theitem.indexOf("selectedObjectIds", 0) + 1; + var appitem = theForm.elements[i].name; + var appcheck = appitem.indexOf("checkBoxes", 0) + 1; + if ((appitem == "checkBoxes1") || (appitem == "checkBoxes2")) { + appcheck = 0; + } + + if (chkname != null) { + var curcheck = theitem.indexOf(chkname.name, 0) + 1; + + } + + if (ischeck > 0) { + if (theForm.elements[i].checked == true) { + checkednum += 1; + } else { + uncheckednum += 1; + } + } + if (curcheck > 0) { + if (theForm.elements[i].checked == true) { + checkednum += 1; + } else { + uncheckednum += 1; + + } + + } + if (appcheck > 0) { + if (theForm.elements[i].checked == true) { + checkednum += 1; + } else { + uncheckednum += 1; + } + + } + + } + + if (allchecked == true) { + + if (uncheckednum > 0) { + allchecked = false; + theForm.allchecked.checked = false; + } + } else { + if (uncheckednum == 0) { + allchecked = true; + theForm.allchecked.checked = true; + + } + } + +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/error.jsp b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/error.jsp new file mode 100755 index 00000000..61baf092 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/error.jsp @@ -0,0 +1,156 @@ + + + + + + + + + + + + + <%@ page import="java.io.*, java.lang.reflect.*"%> + + + + + + + + + + + + + + + + + + + + + +
+
+
An Error has occured + during PlantsByWebSphere processing.
+ <% + String message = null; + int status_code = -1; + String exception_info = null; + String url = null; + String method = null; + + Object myReport = null; + + //ErrorReport is an attribute that is set in WebSphere + //if it exists we will use it to get information about the error + //if it does not exist we will use the attributes specified by + //Servlet 2.2 + myReport = request.getAttribute("ErrorReport"); + + int needInfo = 1; + if (myReport != null) { + try { + //Using reflection here so that if the class com.ibm.websphere.servlet.error.ServletErrorReport + //does not exist at compile time there will not be a problem + //if this class does not exist we will juse use the attributes specified by Servlet 2.2 + + Class myClass = Class.forName("com.ibm.websphere.servlet.error.ServletErrorReport"); + Method myMethod = myClass.getMethod("getErrorCode", (Class[]) null); + Object o = myMethod.invoke(myReport, (Object[]) null); + status_code = ((Integer) o).intValue(); + + myMethod = myClass.getMethod("getMessage", (Class[]) null); + o = myMethod.invoke(myReport, (Object[]) null); + message = (java.lang.String) o; + + myMethod = myClass.getMethod("getStackTrace", (Class[]) null); + o = myMethod.invoke(myReport, (Object[]) null); + exception_info = (java.lang.String) o; + needInfo = 0; + method = "Using attribute of type com.ibm.websphere.servlet.error.ServletErrorReport to get information."; + + } catch (Exception e) { + needInfo = 1; + } + + } + //if needInfo is set to 1 it means that using the WebSphere ServletErrorReport class has failed + //and we must get the information in the standard manner. + if (needInfo == 1) { + //this means that could not find ibm class. + + Exception theException = null; + Integer status = null; + method = "Using attributes javax.servlet.error.message ...status_code ...exception as specified by Servlet 2.2 to get information"; + //these attribute names are specified by Servlet 2.2 + message = (String) request.getAttribute("javax.servlet.error.message"); + status = ((Integer) request.getAttribute("javax.servlet.error.status_code")); + theException = (Exception) request.getAttribute("javax.servlet.error.exception"); + if (message == null) { + message = "not available"; + } + + if (status == null) { + status_code = -1; + } else { + status_code = status.intValue(); + } + if (theException == null) { + exception_info = "not available"; + } else { + exception_info = theException.toString(); + } + } + + try { + url = request.getRequestURL().toString(); + } catch (Exception e) { + url = "information not available"; + } + + //output is all done here. + + out.println("

Jsp Error Page

" + method); + out.println("

Processing request:" + url); + out.println("
StatusCode: " + status_code); + out.println("
Message:" + + message.replace("<", "<").replace(">", ">").replace("\"", """)); + out.println("
Exception:" + + exception_info.replace("<", "<").replace(">", ">").replace("\"", """)); + %> +
Please Check the application server log files + for details...
+
+
+ + + + + +
Plants by WebSphere
+ + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/help.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/help.xhtml new file mode 100755 index 00000000..d27f39c5 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/help.xhtml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + +
+

+ + > +

+
+ + + + + + + + + + + + + + + + + + + +

Help

Plants By WebSphere provides + limited help support. See the sample docs directory for + documentation on the design, building, and installation of + the sample.

+

Debug mode has been tied to the JSF project stage + declaration. Debug messages will be displayed when the web + app's javax.faces.PROJECT_STAGE context param is set to + either Development or UnitTest. A value of SystemTest or + Production will turn off debug output. The current state of + debugging is indicated in the check box below.

Debug messages + enabled
+

If the database becomes corrupted for some reason, the + button below can be used to delete all data currently in the + database and populate it with a fresh set of data. If this + does not work, stop the server and repeat the prerequisite + steps found in the docs directory to unzip the Derby + database.

+

+ +

+
+
+ + + + +
+
+
+
+ + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/index.html b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/index.html new file mode 100755 index 00000000..43371796 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/login.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/login.xhtml new file mode 100755 index 00000000..334f3c38 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/login.xhtml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + +
+

+ +

+
+ + + + + + + + + +

Login or + Register

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ If you are a returning customer and previously set up an + account, please enter your e-mail + address and password below. +

+

+ +

+

+ +    + +

+

+ +

+

+ +

+
+ +
+
+

+ If you are a New customer you can + + . +


+
+
+
+
+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderdone.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderdone.xhtml new file mode 100755 index 00000000..c87f14ba --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderdone.xhtml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + +
+

+ +

+
+ + + + + + + + + +
Order + Completion
+

Thank you for making your Plants By WebSphere purchase!

+
+

+ Order number + +

+
+

Expected arrival in 5-7 business days.

+
+
+
+
+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderinfo.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderinfo.xhtml new file mode 100755 index 00000000..709f9b57 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/orderinfo.xhtml @@ -0,0 +1,516 @@ + + + + + + + + + + + + + + + + + + + +
+

+ + > + +

+
+ + + + + + + + + + + + + + + + + + + +
Checkout

Enter the billing and shipping + information for your order below. Select 'Continue' to review + and place your final order.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Billing Address

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+
 
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Shipping + Information
+ + + + + +
+

+ +   +

+

Check here if the + shipping address is the same as the billing address.

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Shipping Method

Select a shipping method below. + Your order total will be updated on the next page.

+

+ +

+ + + +
 
+

+ +

+
+

+ + + + + + +

+
+

+ +

+
+   
+

+ +

+
+

+ + + + + + + + + + + + + + +

+
+

+ +

+
+

+ + + + + +

+
+

+ +

+
+

+ +    + +

+
+

 

+
+

 

+
+ +
+
+
+
+ + + + + +
+
+
+
+ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/product.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/product.xhtml new file mode 100755 index 00000000..8647dc73 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/product.xhtml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + +
+

+ + > + + + +

+
+ + + + + + + + + + + + + + +
+

+ +

+



+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +

ITEM#DESCRIPTIONPRICEQUANTITY
+
  +
+ + +
+
+
+
+
+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/promo.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/promo.xhtml new file mode 100755 index 00000000..ff63de80 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/promo.xhtml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + +
+
+ +
+
+ +
+ + + + + + +
+ + + + + + + +
Tips

Preserve + extra grass seed by keeping it dry. Tape boxes and bags + closed, or seal them into plastic bags. Be sure to remove + extra air from the bags. Store all seed in a cool, dry area + such as a garage or basement.

+
+ + + + + + + + + + + +
Specials
+ + + +

+ + + + Bonsai Tree +
+ $30.00 each +
+
+

+ + + +

+ + + + Red Delicious Strawberries +
+ $3.50 (50 seeds) +
+
+

+ + + +

+ + + + Tulips +
+ $17.00 (10 bulbs) +
+
+

+
+
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/register.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/register.xhtml new file mode 100755 index 00000000..528d1663 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/register.xhtml @@ -0,0 +1,332 @@ + + + + + + + + + + + + + + + + + +
+

+ + > + +

+
+ + + + + + + + + + + + + + + +

Registration

+ Enter the information below to set up your account. This + information will not be shared without your permission. With + your permission we will only share your name and email address + with our trusted business partners.
+
+

+

+ Required fields are denoted with a red asterisk ( + + ).
+
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Login Information
   

+ +

+

+ + + +    + +

+

+ +

+

+ +

+

+ +

+

+ + + +    + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact + Information
   

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+ +    + +

+

+ +

+

+
+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/1x1_trans.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/1x1_trans.gif new file mode 100755 index 00000000..d6e9b014 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/1x1_trans.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdfeeder.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdfeeder.jpg new file mode 100755 index 00000000..9b99836a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdfeeder.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdhouse.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdhouse.jpg new file mode 100755 index 00000000..c062089a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_birdhouse.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_bulbdigger.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_bulbdigger.jpg new file mode 100755 index 00000000..e156f93c Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_bulbdigger.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_finchfood.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_finchfood.jpg new file mode 100755 index 00000000..bd9559d3 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_finchfood.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_gloves.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_gloves.jpg new file mode 100755 index 00000000..fcbd878a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_gloves.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_grassrake.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_grassrake.jpg new file mode 100755 index 00000000..0adf7d29 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_grassrake.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_handrake.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_handrake.jpg new file mode 100755 index 00000000..9d6a59e5 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_handrake.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_leafrake.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_leafrake.jpg new file mode 100755 index 00000000..09f832a9 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_leafrake.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_pot.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_pot.jpg new file mode 100755 index 00000000..30f7bfc9 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_pot.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_shovel.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_shovel.jpg new file mode 100755 index 00000000..5bd8caa1 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_shovel.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_wheelbarrow.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_wheelbarrow.jpg new file mode 100755 index 00000000..2302d40e Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/accessories_wheelbarrow.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/add_to_cart.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/add_to_cart.jpg new file mode 100755 index 00000000..51b0dd32 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/add_to_cart.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_add_to_cart.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_add_to_cart.gif new file mode 100755 index 00000000..d46ee435 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_add_to_cart.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_change.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_change.gif new file mode 100755 index 00000000..82bca2c9 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_change.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout.gif new file mode 100755 index 00000000..cf3405e1 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout_now.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout_now.gif new file mode 100755 index 00000000..d8db2088 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_checkout_now.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue.gif new file mode 100755 index 00000000..b10e0a8a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue_shopping.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue_shopping.gif new file mode 100755 index 00000000..068db8e3 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_continue_shopping.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_go.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_go.gif new file mode 100755 index 00000000..b3eb969c Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_go.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_more.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_more.gif new file mode 100755 index 00000000..c20f0f30 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_more.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_previous.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_previous.gif new file mode 100755 index 00000000..e9e7d97a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_previous.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_recalculate.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_recalculate.gif new file mode 100755 index 00000000..d5ff1181 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_recalculate.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_register.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_register.gif new file mode 100755 index 00000000..046a9fb2 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_register.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_sign_in.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_sign_in.gif new file mode 100755 index 00000000..5c2a9b25 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_sign_in.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_submit_order.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_submit_order.gif new file mode 100755 index 00000000..d0b3f1ff Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_submit_order.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_update.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_update.gif new file mode 100755 index 00000000..1e2bda89 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/button_update.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/creditcards.bmp b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/creditcards.bmp new file mode 100755 index 00000000..7314a9e1 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/creditcards.bmp differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_african_orchid.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_african_orchid.jpg new file mode 100755 index 00000000..7604aa77 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_african_orchid.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_bbreath.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_bbreath.jpg new file mode 100755 index 00000000..c1178a08 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_bbreath.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_black-eyed_susan.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_black-eyed_susan.jpg new file mode 100755 index 00000000..61724b69 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_black-eyed_susan.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_coleus.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_coleus.jpg new file mode 100755 index 00000000..c2afcaaf Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_coleus.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_daisies.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_daisies.jpg new file mode 100755 index 00000000..1445aa23 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_daisies.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_foxglove.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_foxglove.jpg new file mode 100755 index 00000000..5c70aa00 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_foxglove.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_geranium.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_geranium.jpg new file mode 100755 index 00000000..dac06e51 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_geranium.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_goodnight_moon_iris.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_goodnight_moon_iris.jpg new file mode 100755 index 00000000..565c69ed Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_goodnight_moon_iris.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_impatiens.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_impatiens.jpg new file mode 100755 index 00000000..96d2e675 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_impatiens.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_lily.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_lily.jpg new file mode 100755 index 00000000..c1303c5f Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_lily.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_pansies.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_pansies.jpg new file mode 100755 index 00000000..dc795ad3 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_pansies.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_petunias.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_petunias.jpg new file mode 100755 index 00000000..3da1328c Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_petunias.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_primrose.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_primrose.jpg new file mode 100755 index 00000000..b592e2da Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_primrose.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_poinsettia.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_poinsettia.jpg new file mode 100755 index 00000000..57f8e9a3 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_poinsettia.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_rose.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_rose.jpg new file mode 100755 index 00000000..d88781a5 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_red_rose.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_sparkler_celosia.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_sparkler_celosia.jpg new file mode 100755 index 00000000..f66a6554 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_sparkler_celosia.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips.jpg new file mode 100755 index 00000000..b9dbf24e Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips_48.jpg new file mode 100755 index 00000000..f5c2fa97 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_tulips_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_poinsettia.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_poinsettia.jpg new file mode 100755 index 00000000..ec02a0de Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_poinsettia.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_rose.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_rose.jpg new file mode 100755 index 00000000..3fea521b Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_white_rose.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_zinnia.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_zinnia.jpg new file mode 100755 index 00000000..297b64cc Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/flower_zinnia.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/go.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/go.gif new file mode 100755 index 00000000..8d2d079a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/go.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/item_selection.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/item_selection.jpg new file mode 100755 index 00000000..32e462da Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/item_selection.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/more_btn.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/more_btn.gif new file mode 100755 index 00000000..6e7bde4d Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/more_btn.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/pbw.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/pbw.jpg new file mode 100755 index 00000000..7de65b3a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/pbw.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/poweredby_WebSphere.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/poweredby_WebSphere.gif new file mode 100755 index 00000000..ddbae468 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/poweredby_WebSphere.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/required.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/required.gif new file mode 100755 index 00000000..bda06255 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/required.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/sapling_whitepine_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/sapling_whitepine_48.jpg new file mode 100755 index 00000000..60a85afd Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/sapling_whitepine_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/seeds_promo.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/seeds_promo.gif new file mode 100755 index 00000000..ada56ed5 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/seeds_promo.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/strawberries_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/strawberries_48.jpg new file mode 100755 index 00000000..fed000e0 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/strawberries_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_s.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_s.gif new file mode 100755 index 00000000..73d056c9 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_s.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_u.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_u.gif new file mode 100755 index 00000000..9aeaeb47 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_accessories_u.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_s.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_s.gif new file mode 100755 index 00000000..56699893 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_s.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_u.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_u.gif new file mode 100755 index 00000000..21f25fac Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_flowers_u.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_s.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_s.gif new file mode 100755 index 00000000..0ad57fcf Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_s.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_u.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_u.gif new file mode 100755 index 00000000..cc478e37 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_trees_u.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_s.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_s.gif new file mode 100755 index 00000000..efb55efa Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_s.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_u.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_u.gif new file mode 100755 index 00000000..072737e5 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tab_veggies_u.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background.jpg new file mode 100755 index 00000000..9f3738e7 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_a.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_a.gif new file mode 100755 index 00000000..eb2d540a Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_a.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_b.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_b.gif new file mode 100755 index 00000000..5d4e3c24 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tabs_background_b.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer1.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer1.gif new file mode 100755 index 00000000..648b0797 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer1.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer2.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer2.gif new file mode 100755 index 00000000..c239e0cf Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer2.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer_text.gif b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer_text.gif new file mode 100755 index 00000000..22b8bdbe Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/theme_summer_text.gif differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_ash.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_ash.jpg new file mode 100755 index 00000000..36a5da9d Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_ash.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_aspen.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_aspen.jpg new file mode 100755 index 00000000..51628da3 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_aspen.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai.jpg new file mode 100755 index 00000000..628a9b3e Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai_48.jpg new file mode 100755 index 00000000..7ce5fe8e Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_bonsai_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_crab.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_crab.jpg new file mode 100755 index 00000000..d1b6e5b0 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_crab.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_maple.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_maple.jpg new file mode 100755 index 00000000..36a9b608 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/trees_maple.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tulips_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tulips_48.jpg new file mode 100755 index 00000000..f5c2fa97 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/tulips_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_cabbage.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_cabbage.jpg new file mode 100755 index 00000000..778f2883 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_cabbage.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_gourds.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_gourds.jpg new file mode 100755 index 00000000..3a3ab7a1 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_gourds.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_grapes.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_grapes.jpg new file mode 100755 index 00000000..5b5fb81b Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_grapes.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_onion.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_onion.jpg new file mode 100755 index 00000000..bc4371ad Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_onion.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_pineapple.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_pineapple.jpg new file mode 100755 index 00000000..117ed2d6 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_pineapple.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries.jpg new file mode 100755 index 00000000..2dc87789 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries_48.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries_48.jpg new file mode 100755 index 00000000..fed000e0 Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_strawberries_48.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_watermelon.jpg b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_watermelon.jpg new file mode 100755 index 00000000..f79f088d Binary files /dev/null and b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/images/veggies_watermelon.jpg differ diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/javascript/PlantsScripts.js b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/javascript/PlantsScripts.js new file mode 100755 index 00000000..ca191218 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/javascript/PlantsScripts.js @@ -0,0 +1,88 @@ +// +// COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, +// modify, and distribute these sample programs in any form without payment to IBM for the purposes of +// developing, using, marketing or distributing application programs conforming to the application +// programming interface for the operating platform for which the sample code is written. +// Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS +// AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED +// WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, +// TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE +// SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS +// OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. +// +// (C) COPYRIGHT International Business Machines Corp., 2011 +// All Rights Reserved * Licensed Materials - Property of IBM +// + +if (document.images) { + menu1s = new Image(); + menu1s.src = "resources/images/tab_flowers_s.gif"; + menu2s = new Image(); + menu2s.src = "resources/images/tab_veggies_s.gif"; + menu3s = new Image(); + menu3s.src = "resources/images/tab_trees_s.gif"; + menu4s = new Image(); + menu4s.src = "resources/images/tab_accessories_s.gif"; + + menu1u = new Image(); + menu1u.src = "resources/images/tab_flowers_u.gif"; + menu2u = new Image(); + menu2u.src = "resources/images/tab_veggies_u.gif"; + menu3u = new Image(); + menu3u.src = "resources/images/tab_trees_u.gif"; + menu4u = new Image(); + menu4u.src = "resources/images/tab_accessories_u.gif"; + + } + + function selectMenu (imgName) { + if (top.banner.document.images) { + top.banner.document[imgName].src = eval(imgName + "s.src"); + } + } + + function deselectMenu (imgName) { + if (top.banner.document.images) { + top.banner.document[imgName].src = eval(imgName + "u.src"); + } + } + + function useBill() + { + var billName = document.getElementById ("orderinfo:bname"); + var billAddr1 = document.getElementById ("orderinfo:baddr1"); + var billAddr2 = document.getElementById ("orderinfo:baddr2"); + var billCity = document.getElementById ("orderinfo:bcity"); + var billState = document.getElementById ("orderinfo:bstate"); + var billZip = document.getElementById ("orderinfo:bzip"); + var billPhone = document.getElementById ("orderinfo:bphone"); + var shipName = document.getElementById ("orderinfo:sname"); + var shipAddr1 = document.getElementById ("orderinfo:saddr1"); + var shipAddr2 = document.getElementById ("orderinfo:saddr2"); + var shipCity = document.getElementById ("orderinfo:scity"); + var shipState = document.getElementById ("orderinfo:sstate"); + var shipZip = document.getElementById ("orderinfo:szip"); + var shipPhone = document.getElementById ("orderinfo:sphone"); + var shipIsBill = document.getElementById ("orderinfo:shipisbill"); + + if (shipIsBill.checked) { + shipName.value = billName.value; + shipAddr1.value = billAddr1.value; + shipAddr2.value = billAddr2.value; + shipCity.value = billCity.value; + shipState.value = billState.value; + shipZip.value = billZip.value; + shipPhone.value = billPhone.value; + } + + else { + shipName.value = ""; + shipAddr1.value = ""; + shipAddr2.value = ""; + shipCity.value = ""; + shipState.value = ""; + shipZip.value = ""; + shipPhone.value = ""; + } + } \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain.css b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain.css new file mode 100755 index 00000000..4ff5b50d --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain.css @@ -0,0 +1,321 @@ + +/* -------------------------------- */ + +/* + * COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, + * modify, and distribute these sample programs in any form without payment to IBM for the purposes of + * developing, using, marketing or distributing application programs conforming to the application + * programming interface for the operating platform for which the sample code is written. + * Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS + * AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED + * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, + * TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE + * SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS + * OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. + * + * (C) COPYRIGHT International Business Machines Corp., 2000,2011 + * All Rights Reserved * Licensed Materials - Property of IBM + */ + +/* -------------------------------- */ + + + +/* MAIN FRAME STYLE FOR HELP CONTENT: DO NOT use a class reference */ + +BODY { font-family : Arial, Helvetica, sans-serif; + margin-left:0; margin-right:0; margin-top:0; margin-bottom:0;width:100%;height:100%;overflow:auto } + +BODY.banner { + margin-left: 0px; +} + +DIV { font-family : Arial, Helvetica, sans-serif;} + +DIV.banner { + margin-left: 0px; +} + + +/* Header Properties */ + +H1 { font-size : 14pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H2 { font-size : 15pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H3 { font-size : 12pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + font-style : italic; + + margin-bottom : 0; + color : #669966;} + +H4 { font-size : 11pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H5 { font-size : 10pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + font-style : italic; + + margin-bottom : 0; + color : #669966;} + + +/* Paragraph Properties */ + + +P { font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-top : 0em; + + margin-bottom : 0; + font-size : .8em;} +P.global { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .6em; + margin-top : 4px; + + color : "#ffffff";} +P.search { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .6em;} +P.tips { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #333333;} +P.footer { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #666666;} +P.trail { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #666666;} + + +/* Anchor Properties */ + +A { font-family : Verdana, Arial, Helvetica, sans-serif; + + text-decoration : underline; + + font-weight : normal;} + + +A.global { color: #ffffff;text-decoration: none;font-weight:normal;} + +A:link.global { color: #ffffff;font-weight:normal;text-decoration: none;} + +A:visited.global { color: #ffffff;font-weight:normal;text-decoration: none;} +A:active.global { color: #ffffff;font-weight:normal;text-decoration: none;} + + + +A:hover.global { color: #ffffff;font-weight:normal;text-decoration: underline;} + + + + +A.promos { color: #000000;text-decoration: none;font-weight:normal;} + +A:link.promos { color: #000000;font-weight:normal;text-decoration: none;} + +A:visited.promos { color: #000000;font-weight:normal;text-decoration: none;} +A:active.promos { color: #000000;font-weight:normal;text-decoration: none;} + + + +A:hover.promos { color: #000000;font-weight:normal;text-decoration: none;} + + + + +A.footer { color: #666666;text-decoration: none;font-weight:normal;} + +A:link.footer { color: #666666;font-weight:normal;text-decoration: none;} + +A:visited.footer { color: #666666;font-weight:normal;text-decoration: none;} +A:active.footer { color: #666666;font-weight:normal;text-decoration: none;} + + + +A:hover.footer { color: #666666;font-weight:normal;text-decoration: underline;} + + + + +A.trail { color: #666666;text-decoration: none;font-weight:normal;} + +A:link.trail { color: #666666;font-weight:normal;text-decoration: none;} + +A:visited.trail { color: #666666;font-weight:normal;text-decoration: none;} +A:active.trail { color: #666666;font-weight:normal;text-decoration: none;} + + + +A:hover.trail { color: #666666;font-weight:normal;text-decoration: underline;} + + + + + + + +/* Table Properties */ + +TABLE { font-family : Verdana, Arial, Helvetica, sans-serif; + border : 0; + + margin-top : 0px; + + margin : 0px; + + padding : 0px; + + spacing : 0px + float : none; + + clear : none;} + +TABLE.banner { + border: 0px; + border-spacing: 0px; + padding: 0px; + width: 100%; +} + +TABLE.footer { + border-spacing: 0px; + padding: 5px; + width: 100%; +} + +TH { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .7em; + + font-weight : bold; + text-align : left;} + + + +TH.item { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : bold; + color : #666666; + text-align : left;} + +TH.cartitemleft { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : bold; + color : #666666; + text-align : left; + background-color : #eeeecc; + white-space : nowrap;} + +TH.cartitemright { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : bold; + color : #666666; + text-align : right; + background-color : #eeeecc; + white-space : nowrap;} + +TH.promos { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .7em; + color: white; + font-weight : bold; + padding : 2px; + padding-left : 4px; + color : "#ffffff"; + text-align : left; + + background-color: #669966;} + + +TH.space { background-color: #ffffff; + padding : 0px;} + + +TD { font-family : Verdana, Arial, Helvetica, sans-serif;} + +TD.item { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : normal; + color : #666666; + text-align : left;} + +TD.cartitemleft { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : normal; + color : #666666; + text-align : left; + background-color : #ffffdd; + white-space : nowrap;} + +TD.cartitemright { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : normal; + color : #666666; + text-align : right; + background-color : #ffffdd; + white-space : nowrap;} + +TD.promos { padding : 2px; + padding-left : 4px; + padding-bottom : 4px; + + background-color: #DCEBCD;} + +TD.trail { padding-left : 14px;} + + +TR.cartitem { background-color : #ffffdd;} +TH.cartitem { background-color : #eeeecc;} +TR.carttitle { font-size : 14pt; + font-family : Verdana, Arial, Helvetica, sans-serif; + margin-bottom : 0; + color : #669966;} +TR.cartsubtotal { background-color: #ffffdd; + font-weight: bold; + text-align: right; + align: right } + + +/* Text Formatting Properties */ + +STRONG { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-weight : bold;} + + +TT { font-family : Courier;} + + +CENTER { text-align : center;} + +HR {width: 100%; color: black; height: 1px; shade:no-shade; position: relative} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain_ns.css b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain_ns.css new file mode 100755 index 00000000..70ddf157 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/resources/theme/PlantMain_ns.css @@ -0,0 +1,254 @@ +/* -------------------------------- */ + +/* + * COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, + * modify, and distribute these sample programs in any form without payment to IBM for the purposes of + * developing, using, marketing or distributing application programs conforming to the application + * programming interface for the operating platform for which the sample code is written. + * Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS + * AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED + * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, + * TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE + * SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS + * OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. + * + * (C) COPYRIGHT International Business Machines Corp., 2000,2011 + * All Rights Reserved * Licensed Materials - Property of IBM + */ + +/* -------------------------------- */ + + + +/* MAIN FRAME STYLE FOR HELP CONTENT: DO NOT use a class reference */ + +BODY { font-family : Arial, Helvetica, sans-serif;} + + + + + +/* Header Properties */ + +H1 { font-size : 14pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H2 { font-size : 15pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H3 { font-size : 12pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + font-style : italic; + + margin-bottom : 0; + color : #669966;} + +H4 { font-size : 11pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-bottom : 0; + color : #669966;} + +H5 { font-size : 10pt; + + font-family : Verdana, Arial, Helvetica, sans-serif; + + font-style : italic; + + margin-bottom : 0; + color : #669966;} + + +/* Paragraph Properties */ + + +P { font-family : Verdana, Arial, Helvetica, sans-serif; + + margin-top : 0em; + + margin-bottom : 0; + font-size : .8em;} +P.global { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .6em; + margin-top : 4px; + + color : "#ffffff";} +P.search { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .6em;} +P.tips { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #333333;} +P.footer { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #666666;} +P.trail { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-size : .7em; + color : #666666;} + + +/* Anchor Properties */ + +A { font-family : Verdana, Arial, Helvetica, sans-serif; + + text-decoration : underline; + + font-weight : normal;} + + +A.global { color: #ffffff;text-decoration: none;font-weight:normal;} + +A:link.global { color: #ffffff;font-weight:normal;text-decoration: none;} + +A:visited.global { color: #ffffff;font-weight:normal;text-decoration: none;} +A:active.global { color: #ffffff;font-weight:normal;text-decoration: none;} + + + +A:hover.global { color: #ffffff;font-weight:normal;text-decoration: underline;} + + + + +A.promos { color: #000000;text-decoration: none;font-weight:normal;} + +A:link.promos { color: #000000;font-weight:normal;text-decoration: none;} + +A:visited.promos { color: #000000;font-weight:normal;text-decoration: none;} +A:active.promos { color: #000000;font-weight:normal;text-decoration: none;} + + + +A:hover.promos { color: #000000;font-weight:normal;text-decoration: none;} + + + + +A.footer { color: #666666;text-decoration: none;font-weight:normal;} + +A:link.footer { color: #666666;font-weight:normal;text-decoration: none;} + +A:visited.footer { color: #666666;font-weight:normal;text-decoration: none;} +A:active.footer { color: #666666;font-weight:normal;text-decoration: none;} + + + +A:hover.footer { color: #666666;font-weight:normal;text-decoration: underline;} + + + + +A.trail { color: #666666;text-decoration: none;font-weight:normal;} + +A:link.trail { color: #666666;font-weight:normal;text-decoration: none;} + +A:visited.trail { color: #666666;font-weight:normal;text-decoration: none;} +A:active.trail { color: #666666;font-weight:normal;text-decoration: none;} + + + +A:hover.trail { color: #666666;font-weight:normal;text-decoration: underline;} + + + + + + + +/* Table Properties */ + +TABLE { font-family : Verdana, Arial, Helvetica, sans-serif; + border : 0; + + margin-top : 0px; + + margin : 0px; + + padding : 0px; + + spacing : 0px + float : none; + + clear : none;} + + +TH { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .7em; + + font-weight : bold; + text-align : left;} + + + +TH.item { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : bold; + color : #666666; + text-align : left;} + + + +TH.promos { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .7em; + font-weight : bold; + padding : 2px; + padding-left : 4px; + color : #FFFFFF; + text-align : left; + background-color: #669966;} + + +TH.space { background-color: #ffffff; + padding : 0px;} + + +TD { font-family : Verdana, Arial, Helvetica, sans-serif;} + +TD.item { font-family : Verdana, Arial, Helvetica, sans-serif; + font-size : .6em; + + font-weight : normal; + color : #666666; + text-align : left;} + + +TD.promos { padding : 2px; + padding-left : 4px; + padding-bottom : 4px; + + background-color: #DCEBCD;} + +TD.trail { padding-left : 14px;} + +CAPTION { font-family : Verdana, Arial, Helvetica, sans-serif; + text-align : left;} + + +/* Text Formatting Properties */ + +STRONG { font-family : Verdana, Arial, Helvetica, sans-serif; + + font-weight : bold;} + + +TT { font-family : Courier;} + + +CENTER { text-align : center;} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/shopping.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/shopping.xhtml new file mode 100755 index 00000000..0baa5912 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/shopping.xhtml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + +
+

+ +

+
+ + + + + +
+

+ +

+

Page + 1 of 1

+
+ + + + + + + +
+

+ + + +

+
+
+
+
+ + + + + +
 

Page + 1 of 1

+ + + + +
+
+
+
+
+ \ No newline at end of file diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/supplierconfig.jsp b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/supplierconfig.jsp new file mode 100755 index 00000000..3ee5ee6b --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/supplierconfig.jsp @@ -0,0 +1,291 @@ + + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Supplier Configuration + + + + + + + + + <%@page + import="com.ibm.websphere.samples.pbw.jpa.Supplier,,com.ibm.websphere.samples.pbw.utils.Util,java.util.*" + session="true" isThreadSafe="true" isErrorPage="false"%> + <% + com.ibm.websphere.samples.pbw.jpa.Supplier supplierInfo = (com.ibm.websphere.samples.pbw.jpa.Supplier) session + .getAttribute(com.ibm.websphere.samples.pbw.utils.Util.ATTR_SUPPLIER); + String id = ""; + String name = ""; + String street = ""; + String city = ""; + String state = ""; + String zip = ""; + String phone = ""; + String url = ""; + if (supplierInfo != null) { + id = supplierInfo.getSupplierID(); + name = supplierInfo.getName(); + street = supplierInfo.getStreet(); + city = supplierInfo.getCity(); + state = supplierInfo.getUsstate(); + zip = supplierInfo.getZip(); + phone = supplierInfo.getPhone(); + url = supplierInfo.getUrl(); + } + %> + + + + + + + + + + +
+

+ Admin + Home +

+
+ + + + + + + + +
+

Supplier Configuration

+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Enter the Supplier's Configuration Information
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+

+ +

+
+ +
+
+ + + + + + +
+

+
+

+ + + + + + + +
Powered by WebSphere + +
+ + diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/theme/stylesheet.css b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/theme/stylesheet.css new file mode 100755 index 00000000..fb54e566 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/theme/stylesheet.css @@ -0,0 +1,187 @@ +/* + * COPYRIGHT LICENSE: This information contains sample code provided in source code form. You may copy, + * modify, and distribute these sample programs in any form without payment to IBM for the purposes of + * developing, using, marketing or distributing application programs conforming to the application + * programming interface for the operating platform for which the sample code is written. + * Notwithstanding anything to the contrary, IBM PROVIDES THE SAMPLE SOURCE CODE ON AN "AS IS" BASIS + * AND IBM DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED + * WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, + * TITLE, AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. IBM SHALL NOT BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR OPERATION OF THE + * SAMPLE SOURCE CODE. IBM HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS + * OR MODIFICATIONS TO THE SAMPLE SOURCE CODE. + * + * (C) COPYRIGHT International Business Machines Corp., 2000,2011 + * All Rights Reserved * Licensed Materials - Property of IBM + */ + + /******************************** + * Faces Components Stylesheet * + ********************************/ + +.form { +} + +.commandLink { +} + +.outputLink { +} + +.link { +} + +.graphicImage { +} + +.outputLabel { +} + +.inputText { +} + +.inputText_Error { + border-style: solid; + border-color: #DE5C5C; +} + +.inputTextarea { +} + +.inputSecret { +} + +.inputHidden { +} + +.outputText { +} + +.outputFormat { +} + +.commandButton { +} + +.button { +} + +.message { +} + +.messages { +} + +.selectBooleanCheckbox { +} + +.selectBooleanCheckbox_Error { +} + +.selectOneRadio { +} + +.selectOneRadio_Error { +} + +.selectOneRadio_Disabled { + color: GrayText; +} + +.selectManyCheckbox { +} + +.selectManyCheckbox_Error { +} + +.selectManyCheckbox_Disabled { + color: GrayText; +} + +.selectOneListbox { +} + +.selectOneListbox_Error { +} + +.selectManyListbox { +} + +.selectManyListbox_Error { +} + +.selectOneMenu { +} + +.selectOneMenu_Error { +} + +.selectManyMenu { +} + +.selectManyMenu_Error { +} + +.panelGroup { +} + +.panelGrid { +} + +.dataTable { + empty-cells:show; +} + +.headerClass { + background-color: ThreeDFace; + color: WindowText; + border-width: 1px; + border-style: solid; + border-color: ThreeDShadow; + margin:2px; + padding:0px; + padding-left:4pt; + padding-right:4pt; + padding-bottom:2px; + font-weight: 400; + overflow: -moz-scrollbars-none; +} + +.footerClass { + background-color: ThreeDFace; + color: WindowText; + border-width: 0px; + border-style: none; + padding:0px; + padding-left:4pt; + padding-right:4pt; + font-weight: 400; + overflow: -moz-scrollbars-none; +} + +.rowClass1 { + background-color: window; +} + +.rowClass2 { + background-color: ThreeDFace; +} + +.columnClass1 { + background-color: window; + margin:2px; + padding:0px; + padding-left:4pt; + padding-right:4pt; + padding-bottom:2px; + overflow: -moz-scrollbars-none; +} + +.columnClass2 { + background-color: ThreeDFace; + margin:2px; + padding:0px; + padding-left:4pt; + padding-right:4pt; + padding-bottom:2px; +} diff --git a/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/viewExpired.xhtml b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/viewExpired.xhtml new file mode 100755 index 00000000..8cb4cec3 --- /dev/null +++ b/src/test/resources/test-applications/plantsbywebsphere/src/main/webapp/viewExpired.xhtml @@ -0,0 +1,35 @@ + + + + + + + + + + Your shopping session has expired due to inactivity. Your shopping cart and all items in it has been lost. You may continue + to shop. Any new items placed in your shopping cart will be remembered. + + + \ No newline at end of file