package foundation.capacity;
|
|
import java.util.List;
|
|
import foundation.capacity.role.Role;
|
import foundation.capacity.sight.Sight;
|
import foundation.data.entity.Entity;
|
import foundation.json.IJSONWriter;
|
import foundation.util.MapList;
|
|
public class Actor {
|
|
public static String Code_Org = "Org";
|
public static String Code_Position = "Position";
|
public static String Code_Employee = "Employee";
|
public static String Code_User = "User";
|
private String id;
|
private String code;
|
private String name;
|
private String type;
|
private MapList<String, Capacity> capacitys;
|
private CapacityRuntime capacityRuntime;
|
|
|
public Actor() {
|
capacitys = new MapList<String, Capacity>();
|
capacityRuntime = new CapacityRuntime();
|
}
|
|
public static Actor getInstance(String actorId) {
|
Actor actor = ActorBucket.getInstance().get(actorId);
|
return actor;
|
}
|
|
public void load(Entity entity) {
|
id = entity.getString("id");
|
code = entity.getString("code");
|
name = entity.getString("name");
|
type = entity.getString("actor_type");
|
}
|
|
public void buildCapacityRuntime() {
|
for (Capacity capacity: capacitys) {
|
capacityRuntime.merge(capacity);
|
}
|
}
|
|
public void loadOneCapacity(Capacity capacity) {
|
capacitys.add(capacity.getId(), capacity);
|
}
|
|
public List<Capacity> getCapacitys() {
|
return capacitys.getItemList();
|
}
|
|
public Role getRoleRuntime() {
|
return capacityRuntime.getRole();
|
}
|
|
public Sight getSightRuntime() {
|
return capacityRuntime.getSight();
|
}
|
|
public String getId() {
|
return id;
|
}
|
|
public String getCode() {
|
return code;
|
}
|
|
public String getName() {
|
return name;
|
}
|
|
public String getType() {
|
return type;
|
}
|
|
public void writeJSON(IJSONWriter writer) {
|
writer.beginObject();
|
writeJSONBody(writer);
|
writer.endObject();
|
}
|
|
public void writeJSONBody(IJSONWriter writer) {
|
writer.write("actor_id", id);
|
writer.write("name", name);
|
writer.write("actor_type", type);
|
}
|
|
}
|