OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 141 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
112 ilm 1
package org.openconcerto.modules.operation;
2
 
3
import java.util.List;
4
 
5
import org.jopencalendar.model.Flag;
6
import org.jopencalendar.model.JCalendarItem;
150 ilm 7
import org.openconcerto.sql.element.SQLElementDirectory;
8
import org.openconcerto.sql.model.SQLRowValues;
9
import org.openconcerto.utils.CollectionUtils;
112 ilm 10
 
11
public class JCalendarItemDB extends JCalendarItem {
150 ilm 12
    private final SQLRowValues item;
13
    private final SQLRowValues group;
14
    private final OperationSQLElement operationElem;
15
    private final SQLRowValues operation;
112 ilm 16
    private String status;
17
    private String type;
18
    private String plannerXML;
19
    private String plannerUID;
20
    private String siteName;
21
    private String siteComment;
22
    private Number siteId;
23
 
150 ilm 24
    public JCalendarItemDB(final SQLElementDirectory dir, final SQLRowValues r) {
25
        assert r.isFrozen();
26
        this.item = r;
27
        this.group = dir.getElement(this.item.getTable()).getContainer(this.item);
28
        this.operationElem = dir.getElement(OperationSQLElement.class);
29
        this.operation = CollectionUtils.getSole(this.group.getReferentRows(this.operationElem.getTable()));
112 ilm 30
    }
31
 
150 ilm 32
    // OK since frozen
33
    public final SQLRowValues getRow() {
34
        return this.item;
112 ilm 35
    }
36
 
150 ilm 37
    public final OperationSQLElement getSourceElement() {
38
        return this.operationElem;
112 ilm 39
    }
40
 
150 ilm 41
    // OK since frozen
42
    public final SQLRowValues getSource() {
43
        return this.operation;
112 ilm 44
    }
45
 
150 ilm 46
    public final boolean isPlanned() {
47
        // there's also a flag "planned" but it's for the UI
48
        return !this.getSource().getString("PLANNER_UID").isEmpty();
49
    }
50
 
51
    // OK since frozen
52
    public final SQLRowValues getUserRow() {
53
        return (SQLRowValues) this.getSource().getForeign("ID_USER_COMMON");
54
    }
55
 
56
    // OK since frozen
57
    public final SQLRowValues getCalendarGroup() {
58
        return this.group;
59
    }
60
 
141 ilm 61
    public int getIdCalendarGroup() {
150 ilm 62
        return this.getCalendarGroup().getID();
112 ilm 63
    }
64
 
65
    @Override
66
    public int hashCode() {
150 ilm 67
        return this.getId();
112 ilm 68
    }
69
 
70
    @Override
71
    public boolean equals(Object obj) {
150 ilm 72
        if (this == obj)
73
            return true;
74
        if (obj == null)
75
            return false;
76
        if (getClass() != obj.getClass())
77
            return false;
78
        final JCalendarItemDB o = (JCalendarItemDB) obj;
79
        return this.item.equalsAsRow(o.item);
112 ilm 80
    }
81
 
82
    public void setOperationStatus(String status) {
83
        this.status = status;
84
    }
85
 
86
    public String getStatus() {
87
        return status;
88
    }
89
 
90
    public void setOperationType(String type) {
91
        this.type = type;
92
    }
93
 
94
    public String getType() {
95
        return type;
96
    }
97
 
98
    public String getFlagsString() {
99
        final List<Flag> flags = getFlags();
100
        final int size = flags.size();
101
        String str = "";
102
        for (int i = 0; i < size; i++) {
103
            str += flags.get(i).getTypeId();
104
            if (i < size - 1) {
105
                str += ",";
106
            }
107
        }
108
        return str;
109
    }
110
 
111
    public String getPlannerXML() {
112
        return plannerXML;
113
    }
114
 
115
    public void setPlannerXML(String string) {
116
        this.plannerXML = string;
117
    }
118
 
119
    public String getPlannerUID() {
120
        return plannerUID;
121
    }
122
 
123
    public void setPlannerUID(String plannerUID) {
124
        this.plannerUID = plannerUID;
125
    }
126
 
127
    public String getSiteName() {
128
        return siteName;
129
    }
130
 
131
    public void setSiteName(String siteName) {
132
        this.siteName = siteName;
133
    }
134
 
135
    public String getSiteComment() {
136
        return siteComment;
137
    }
138
 
139
    public void setSiteComment(String siteComment) {
140
        this.siteComment = siteComment;
141
    }
142
 
143
    public void setSiteId(Number idNumber) {
144
        this.siteId = idNumber;
145
    }
146
 
147
    public Number getSiteId() {
148
        return siteId;
149
    }
141 ilm 150
 
151
    public int getId() {
150 ilm 152
        return this.getRow().getID();
141 ilm 153
    }
112 ilm 154
}