P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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);
    }
 
}