hs.hsadmin/hsarback/src/de/hsadmin/mods/pac/BaseComponent.java

115 lines
2.6 KiB
Java
Raw Normal View History

2010-10-01 21:52:51 +02:00
package de.hsadmin.mods.pac;
import static javax.persistence.GenerationType.SEQUENCE;
import java.io.Serializable;
2010-10-06 15:06:01 +02:00
import javax.persistence.Column;
import javax.persistence.Entity;
2010-10-01 21:52:51 +02:00
import javax.persistence.EntityManager;
2010-10-06 15:06:01 +02:00
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
2010-10-01 21:52:51 +02:00
import de.hsadmin.mods.user.UnixUser;
2010-10-06 15:06:01 +02:00
@Entity(name = "BaseComponents")
2011-03-22 23:02:06 +01:00
@Table(name = "basecomponent")
2010-10-06 15:06:01 +02:00
@SequenceGenerator(name = "BaseComponentsSeqGen", sequenceName = "basecomponent_basecomponent_seq")
2010-10-04 19:44:49 +02:00
public class BaseComponent extends de.hsadmin.core.model.AbstractEntity implements Serializable {
2010-10-01 21:52:51 +02:00
private static final long serialVersionUID = -8161827018235142603L;
2010-10-06 15:06:01 +02:00
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "BaseComponentsSeqGen")
@Column(name = "basecomponent_id", columnDefinition = "integer")
2011-03-22 23:02:06 +01:00
private long baseComponentId;
2010-10-01 21:52:51 +02:00
2010-10-06 15:06:01 +02:00
@Column(name = "basecomponent_code", columnDefinition = "character varying(10)")
2010-10-01 21:52:51 +02:00
private String feature;
2010-10-06 15:06:01 +02:00
@Column(name = "description", columnDefinition = "character varying(100)")
2010-10-01 21:52:51 +02:00
private String description;
2010-10-06 15:06:01 +02:00
@Column(name = "sorting", columnDefinition = "integer")
2010-10-01 21:52:51 +02:00
private int sorting;
2010-10-06 15:06:01 +02:00
@Column(name = "valid", columnDefinition = "boolean")
2010-10-01 21:52:51 +02:00
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) {
2011-08-29 16:09:20 +02:00
return "obj.feature='" + humanKey + "'";
2010-10-01 21:52:51 +02:00
}
@Override
public String createStringKey() {
return getFeature();
}
@Override
public long id() {
2011-03-22 23:02:06 +01:00
return baseComponentId;
2010-10-01 21:52:51 +02:00
}
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() {
2011-03-22 23:02:06 +01:00
return baseComponentId == 0;
2010-10-01 21:52:51 +02:00
}
@Override
public UnixUser owningUser(EntityManager em) {
return null; // TODO: kinda somebody like root needed
}
2011-03-22 23:02:06 +01:00
public void setBaseComponentId(long baseComponentId) {
this.baseComponentId = baseComponentId;
}
public long getBaseComponentId() {
return baseComponentId;
}
2010-10-01 21:52:51 +02:00
}