// Tag.java
//
// (c) SZE-Development-Team

package de.ppi.samples.fuwesta.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;

import de.ppi.fuwesta.jpa.helper.JPAList;
import de.ppi.fuwesta.jpa.helper.VersionedModel;

/**
 * A tag which is used to mark a posting.
 * 
 */
@Entity
public class Tag extends VersionedModel {

    /** The name of the Tag. */
    @Column(nullable = false, unique = true)
    private String name;

    /**
     * Flag if the tag is active.
     */
    private boolean active = true;

    /**
     * The list of postings which have this tag.
     */
    @ManyToMany()
    private List<Post> postings;

    /**
     * Gets the name of the Tag.
     * 
     * @return the name of the Tag
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the name of the Tag.
     * 
     * @param name the new name of the Tag
     */
    public void setName(final String name) {
        this.name = name;
    }

    /**
     * Checks if is flag if the tag is active.
     * 
     * @return the flag if the tag is active
     */
    public boolean isActive() {
        return active;
    }

    /**
     * Sets the flag if the tag is active.
     * 
     * @param active the new flag if the tag is active
     */
    public void setActive(boolean active) {
        this.active = active;
    }

    /**
     * Gets the list of postings which have this tag.
     * 
     * @return the list of postings which have this tag
     */
    public List<Post> getPostings() {
        return getPostingsInternal();
    }

    /**
     * Sets the list of postings which have this tag.
     * 
     * @param postings the new list of postings which have this tag
     */
    public void setPostings(final List<Post> postings) {
        getPostingsInternal().set(postings);
    }

    /**
     * Delivers definitely a {@link PostList}.
     * 
     * @return a PostList which wraps the internal list.
     */
    private PostList getPostingsInternal() {
        if (postings == null) {
            postings = new ArrayList<Post>();
        }
        return new PostList(postings, this);
    }

    /**
     * List which handles the association between {@link Tag} and {@link Post}.
     * 
     */
    private static final class PostList extends JPAList<Post, Tag> {

        /**
         * Initiates an object of type TagList.
         * 
         * @param internalList the internal list
         * @param associatedEntity the entity which holds the list
         */
        public PostList(List<Post> internalList, Tag associatedEntity) {
            super(internalList, associatedEntity);
        }

        /**
         * {@inheritDoc}
         */
        @Override
        public void add(Post entity, Tag associatedEntity) {
            entity.getTags().add(associatedEntity);

        }

        /**
         * {@inheritDoc}
         */
        @Override
        public void remove(Post entity, Tag associatedEntity) {
            entity.getTags().remove(associatedEntity);
        }

    }
}

@@ -80,36 +80,8 @@
 l;%0A%0A
-import java.util.ArrayList;%0A
 impo
@@ -99,16 +99,16 @@
 l.List;%0A
+
 %0Aimport 
@@ -208,50 +208,8 @@
 y;%0A%0A
-import de.ppi.fuwesta.jpa.helper.JPAList;%0A
 impo
@@ -1561,37 +1561,24 @@
  return 
-getP
+p
 ostings
-Internal()
 ;%0A    %7D%0A
@@ -1793,1262 +1793,33 @@
     
-getPostingsInternal().set(postings);%0A    %7D%0A%0A    /**%0A     * Delivers definitely a %7B@link PostList%7D.%0A     * %0A     * @return a PostList which wraps the internal list.%0A     */%0A    private PostList getPostingsInternal() %7B%0A        if (postings == null) %7B%0A            postings = new ArrayList%3CPost%3E();%0A        %7D%0A        return new PostList(postings, this);%0A    %7D%0A%0A    /**%0A     * List which handles the association between %7B@link Tag%7D and %7B@link Post%7D.%0A     * %0A     */%0A    private static final class PostList extends JPAList%3CPost, Tag%3E %7B%0A%0A        /**%0A         * Initiates an object of type TagList.%0A         * %0A         * @param internalList the internal list%0A         * @param associatedEntity the entity which holds the list%0A         */%0A        public PostList(List%3CPost%3E internalList, Tag associatedEntity) %7B%0A            super(internalList, associatedEntity);%0A        %7D%0A%0A        /**%0A         * %7B@inheritDoc%7D%0A         */%0A        @Override%0A        public void add(Post entity, Tag associatedEntity) %7B%0A            entity.getTags().add(associatedEntity);%0A%0A        %7D%0A%0A        /**%0A         * %7B@inheritDoc%7D%0A         */%0A        @Override%0A        public void remove(Post entity, Tag associatedEntity) %7B%0A            entity.getTags().remove(associatedEntity);%0A        %7D%0A
+this.postings = postings;
 %0A   

Remove the unecessary part for taglist because we are on the owning side.