Author: allee8285
Date: Thu Apr 25 22:07:47 2013
New Revision: 1475985

URL: http://svn.apache.org/r1475985
Log:
OPENJPA-2371 - move gallery examples from main to test folder

Added:
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java
   (with props)
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java
   (with props)
Removed:
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/ImageType.java
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/constraint/
    
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/main/java/org/apache/openjpa/example/gallery/model/
Modified:
    openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/pom.xml

Modified: openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/pom.xml
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/pom.xml?rev=1475985&r1=1475984&r2=1475985&view=diff
==============================================================================
--- openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/pom.xml (original)
+++ openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/pom.xml Thu Apr 25 
22:07:47 2013
@@ -94,9 +94,9 @@
           <executions>
             <execution>
               <id>enhancer</id>
-              <phase>process-classes</phase>
+              <phase>process-test-classes</phase>
               <goals>
-                <goal>enhance</goal>
+                <goal>test-enhance</goal>
               </goals>
             </execution>
           </executions>

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery;
+
+public enum ImageType {
+    JPEG,
+    GIF
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/ImageType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+import org.apache.openjpa.example.gallery.ImageType;
+import static org.apache.openjpa.example.gallery.ImageType.GIF;
+import static org.apache.openjpa.example.gallery.ImageType.JPEG;
+
+/**
+ * Type-level annotation used to specify an image constraint.  Uses 
+ * ImageValidator to perform the validation.
+ */
+@Documented
+@Constraint(validatedBy = ImageValidator.class)
+@Target({ TYPE })
+@Retention(RUNTIME)
+public @interface ImageConstraint {
+    String message() default "Image data is not a supported format.";
+    Class<?>[] groups() default {};
+    Class<? extends Payload>[] payload() default {};
+    ImageType[] value() default { GIF, JPEG };
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageConstraint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+import org.apache.openjpa.example.gallery.ImageType;
+import static org.apache.openjpa.example.gallery.ImageType.GIF;
+import static org.apache.openjpa.example.gallery.ImageType.JPEG;
+
+/**
+ * Attribute-level annotation used to specify an image content constraint.  
Uses 
+ * ImageContentValidator to perform the validation.
+ */
+@Documented
+@Constraint(validatedBy = ImageContentValidator.class)
+@Target({ METHOD, FIELD })
+@Retention(RUNTIME)
+public @interface ImageContent {
+    String message() default "Image data is not a supported format.";
+    Class<?>[] groups() default {};
+    Class<? extends Payload>[] payload() default {};
+    ImageType[] value() default { GIF, JPEG };
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.apache.openjpa.example.gallery.ImageType;
+
+/**
+ * Simple check that file format is of a supported type
+ */
+public class ImageContentValidator implements 
ConstraintValidator<ImageContent, byte[]> {
+
+    private List<ImageType> allowedTypes = null;
+    /**
+     * Configure the constraint validator based on the image
+     * types it should support.
+     * @param constraint the constraint definition
+     */
+    public void initialize(ImageContent constraint) {
+        allowedTypes = Arrays.asList(constraint.value());
+    }
+
+    /**
+     * Validate a specified value.
+     */
+    public boolean isValid(byte[] value, ConstraintValidatorContext context) {
+        if (value == null) {
+            return false;
+        }
+        // Verify the GIF header is either GIF87 or GIF89
+        if (allowedTypes.contains(ImageType.GIF)) {
+            String gifHeader = new String(value, 0, 6);
+            if (value.length >= 6 &&
+                (gifHeader.equalsIgnoreCase("GIF87a") ||
+                 gifHeader.equalsIgnoreCase("GIF89a"))) {
+                return true;
+            }
+        }
+        // Verify the JPEG begins with SOI & ends with EOI
+        if (allowedTypes.contains(ImageType.JPEG)) {
+            if (value.length >= 4 &&
+                value[0] == 0xff && value[1] == 0xd8 &&
+                value[value.length - 2] == 0xff &&
+                value[value.length -1] == 0xd9) {
+                return true;
+            }
+        }
+        // Unknown file format
+        return false;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageContentValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+/**
+ * Simple interface used to specify validation group: ImageGroup
+ */
+public interface ImageGroup {
+
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+import org.apache.openjpa.example.gallery.ImageType;
+import org.apache.openjpa.example.gallery.model.Image;
+
+/**
+ * Simple validator used to verify that image data is of a supported type
+ */
+public class ImageValidator implements ConstraintValidator<ImageConstraint, 
Image> {
+
+    private List<ImageType> allowedTypes = null;
+    /**
+     * Configure the constraint validator based on the image
+     * types it should support.
+     * @param constraint the constraint definition
+     */
+    public void initialize(ImageConstraint constraint) {
+        allowedTypes = Arrays.asList(constraint.value());
+    }
+
+    /**
+     * Validate a specified value.
+     */
+    public boolean isValid(Image value, ConstraintValidatorContext context) {
+        // JSR-303 best practice.  Promotes the use of @NotNull to perform
+        // null checking.
+        if (value == null) {
+            return true;
+        }
+        
+        // All these values will be pre-validated with @NotNull constraints
+        // so they are safe to use
+        byte[] data = value.getData();
+        String fileName = value.getFileName();
+        ImageType type = value.getType();
+        
+        // Verify the GIF type is correct, has the correct extension and
+        // the data header is either GIF87 or GIF89
+        if (allowedTypes.contains(ImageType.GIF) &&
+            type == ImageType.GIF &&
+            fileName.endsWith(".gif")) {
+            if (data != null && data.length >= 6) {
+                String gifHeader = new String(data, 0, 6);
+                if (gifHeader.equalsIgnoreCase("GIF87a") ||
+                     gifHeader.equalsIgnoreCase("GIF89a")) {
+                    return true;
+                }
+            }
+        }
+        // Verify the JPEG type is correct, has the correct extension and
+        // the data begins with SOI & ends with EOI markers
+        if (allowedTypes.contains(ImageType.JPEG) &&
+                value.getType() == ImageType.JPEG &&
+                (fileName.endsWith(".jpg") ||
+                 fileName.endsWith(".jpeg"))) {
+            if (data.length >= 4 &&
+                    data[0] == 0xff && data[1] == 0xd8 &&
+                    data[data.length - 2] == 0xff &&
+                    data[data.length - 1] == 0xd9) {
+                return true;
+            }
+        }
+        // Unknown file format
+        return false;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/ImageValidator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.constraint;
+
+import javax.validation.GroupSequence;
+import javax.validation.groups.Default;
+
+/**
+ * Sequenced validation group definition.  When this validation group is
+ * used constraints within the Default group will validate first.  If 
+ * successful, constraints within the ImageGroup will validate next.
+ */
+@GroupSequence({Default.class, ImageGroup.class})
+public interface SequencedImageGroup {
+
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/constraint/SequencedImageGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.model;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.ManyToMany;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Album entity.  Contains references to zero or more images and zero or more
+ * image creators/authors.
+ */
+@Entity
+public class Album {
+
+    @Id
+    @GeneratedValue
+    private long id;
+    
+    @NotNull
+    private String name;
+    
+    @OneToMany
+    private List<Image> images;
+    
+    @ManyToMany
+    private List<Creator> creator;
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setImages(List<Image> images) {
+        this.images = images;
+    }
+
+    public List<Image> getImages() {
+        return images;
+    }
+
+    public void setCreator(List<Creator> creator) {
+        this.creator = creator;
+    }
+
+    public List<Creator> getCreator() {
+        return creator;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Album.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.model;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.validation.constraints.NotNull;
+
+/**
+ * Creator entity.  Contains a reference to one or more images authored by
+ * an instance of the creator.
+ */
+@Entity
+public class Creator {
+
+    @Id
+    @GeneratedValue
+    private long id;
+    
+    @NotNull(message="Photographer's first name must be specified.")
+    private String firstName;
+    
+    @NotNull(message="Photographer's last name must be specified.")
+    private String lastName;
+
+    @OneToMany
+    @OrderBy("fileName")
+    private List<Image> images;
+    
+    @ManyToMany
+    private List<Album> albums;
+    
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setFirstName(String firstName) {
+        this.firstName = firstName;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public void setLastName(String lastName) {
+        this.lastName = lastName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public void setImages(List<Image> images) {
+        this.images = images;
+    }
+
+    public List<Image> getImages() {
+        return images;
+    }
+
+    public List<Album> getAlbums() {
+        return albums;
+    }
+
+    public void setAlbums(List<Album> albums) {
+        this.albums = albums;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Creator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+package org.apache.openjpa.example.gallery.model;
+
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+
+import org.apache.openjpa.example.gallery.ImageType;
+import org.apache.openjpa.example.gallery.constraint.ImageConstraint;
+import org.apache.openjpa.example.gallery.constraint.ImageGroup;
+
+/**
+ * Image entity which makes use of several BV constraints.
+ */
+@Entity
+@ImageConstraint(groups=ImageGroup.class)
+public class Image {
+    
+    private long id;
+    private ImageType type;
+    private String fileName;
+    private byte[] data;    
+    private Location location;
+    private Creator creator;
+    
+    @Id
+    @GeneratedValue
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    @NotNull(message="Image type must be specified.")
+    @Enumerated(EnumType.STRING)
+    public ImageType getType() {
+        return type;
+    }
+    
+    public void setType(ImageType type) {
+        this.type = type;
+    }
+    
+    @NotNull(message="Image file name must not be null.")
+    public String getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    @NotNull(message="Image data must not be null.")
+    public byte[] getData() {
+        return data;
+    }
+
+    public void setData(byte[] data) {
+        this.data = data;
+    }
+
+    @Valid
+    @Embedded
+    public Location getLocation() {
+        return location;
+    }
+
+    public void setLocation(Location location) {
+        this.location = location;
+    }
+
+    @ManyToOne
+    public Creator getCreator() {
+        return creator;
+    }
+
+    public void setCreator(Creator creator) {
+        this.creator = creator;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Image.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java
URL: 
http://svn.apache.org/viewvc/openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java?rev=1475985&view=auto
==============================================================================
--- 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java
 (added)
+++ 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java
 Thu Apr 25 22:07:47 2013
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.openjpa.example.gallery.model;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+/**
+ * Location embeddable with several BV constraints applied.
+ */
+@Embeddable
+public class Location {
+
+    @NotNull(message="City must be specified.")
+    private String city;
+    
+    private String street;
+    
+    private String state;
+
+    @NotNull(message="Country must be specified.")
+    @Size(message="Country must be 50 characters or less.", max=50)
+    @Column(length=50)
+    private String country;
+    
+    @Size(message="Zip code must be 10 characters or less.", max=10)
+    @Pattern(message="Zip code must be 5 digits or use the 5+4 format.",
+        regexp="^\\d{5}(([\\-]|[\\+])\\d{4})?$")
+    @Column(length=10)
+    private String zipCode;
+
+    public void setCity(String city) {
+        this.city = city;
+    }
+
+    public String getCity() {
+        return city;
+    }
+
+    public void setStreet(String street) {
+        this.street = street;
+    }
+
+    public String getStreet() {
+        return street;
+    }
+
+    public void setState(String state) {
+        this.state = state;
+    }
+
+    public String getState() {
+        return state;
+    }
+
+    public void setCountry(String country) {
+        this.country = country;
+    }
+
+    public String getCountry() {
+        return country;
+    }
+
+    public void setZipCode(String zipCode) {
+        this.zipCode = zipCode;
+    }
+
+    public String getZipCode() {
+        return zipCode;
+    }
+}

Propchange: 
openjpa/branches/2.2.1.x/openjpa-examples/image-gallery/src/test/java/org/apache/openjpa/example/gallery/model/Location.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to