hefeixia
2021-02-18 5b8c95c760840f09910730943b21391e47187315
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
package chat.module.entity;
 
import java.util.List;
 
import chat.module.ModuleLoader;
import chat.user.User;
import frame.object.data.DataObject;
import frame.object.data.Entity;
import frame.object.data.ID;
 
public class PrivateFriend extends MessageContainer {
 
    private String id;
    private String typecode;
    private String name;
    private String statuscode;
    private String portrait;
    private String ownerid;
    private long timestamp;
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getTypecode() {
        return typecode;
    }
    
    public void setTypecode(String typecode) {
        this.typecode = typecode;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getStatuscode() {
        return statuscode;
    }
    
    public void setStatuscode(String statuscode) {
        this.statuscode = statuscode;
    }
    
    public String getPortrait() {
        return portrait;
    }
    
    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }
    
    public String getOwnerid() {
        return ownerid;
    }
    
    public void setOwnerid(String ownerid) {
        this.ownerid = ownerid;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    public PrivateFriend() {
        super();
    }
    
    public void createPrivateFriend() {
        DataObject dataObject; 
        Entity entity;
        try {
             //1. insert group
             dataObject = DataObject.getInstance("chatspace");
            
             entity = dataObject.newEntity();
             pushTo(entity);
                
             dataObject.insertToDataBase(entity); 
             
        } catch(Exception e) {
             e.printStackTrace();
        }
        
    }
    
    public PrivateFriend(String name, User sender) {
        super(name, sender);
        this.id = ID.newValue();
        this.typecode = "Private";
        this.name = name;
        this.statuscode = "Open";
        this.ownerid = sender.getId();
        this.timestamp = System.currentTimeMillis();
    }
 
    public void load(Entity entity) {
        id = entity.getString("id");
        typecode = entity.getString("typecode");
        name = entity.getString("name");
        statuscode = entity.getString("statuscode");
        portrait = entity.getString("portrait");
        ownerid = entity.getString("ownerid");
        timestamp = Long.parseLong(entity.getString("timestamp"));
    }
    
    public void pushTo(Entity entity) throws Exception {
        entity.set("id", id);
        entity.set("typecode", typecode);
        entity.set("name", name);
        entity.set("statuscode", statuscode);
        entity.set("portrait", portrait);
        entity.set("ownerid", ownerid);
        entity.set("timestamp", timestamp);
    }
 
}