package de.hsadmin.mods.pac; import static javax.persistence.GenerationType.SEQUENCE; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import de.hsadmin.mods.user.UnixUser; @Entity(name = "BaseComponents") @Table(name = "basecomponent") @SequenceGenerator(name = "BaseComponentsSeqGen", sequenceName = "basecomponent_basecomponent_seq") public class BaseComponent extends de.hsadmin.core.model.AbstractEntity implements Serializable { private static final long serialVersionUID = -8161827018235142603L; @Id @GeneratedValue(strategy = SEQUENCE, generator = "BaseComponentsSeqGen") @Column(name = "basecomponent_id", columnDefinition = "integer") private long baseComponentId; @Column(name = "basecomponent_code", columnDefinition = "character varying(10)") private String feature; @Column(name = "description", columnDefinition = "character varying(100)") private String description; @Column(name = "sorting", columnDefinition = "integer") private int sorting; @Column(name = "valid", columnDefinition = "boolean") private boolean valid; public BaseComponent() { } public BaseComponent(String feature, String desc, int sortPos, boolean valid) { this.feature = feature; this.description = desc; this.sorting = sortPos; this.valid = valid; } public static String createQueryFromStringKey(String humanKey) { return "obj.feature='" + humanKey + "'"; } @Override public String createStringKey() { return getFeature(); } @Override public long id() { return baseComponentId; } public String getFeature() { return feature; } public void setFeature(String code) { this.feature = code; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public int getSorting() { return sorting; } public void setSorting(int sorting) { this.sorting = sorting; } public boolean getValid() { return valid; } public void setValid(boolean valid) { this.valid = valid; } @Override public boolean isNew() { return baseComponentId == 0; } @Override public UnixUser owningUser(EntityManager em) { return null; // TODO: kinda somebody like root needed } public void setBaseComponentId(long baseComponentId) { this.baseComponentId = baseComponentId; } public long getBaseComponentId() { return baseComponentId; } }