001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.common.entity.properties.v1;
009:
010: //base classes
011: import java.util.ArrayList;
012:
013: //project specific classes
014: import org.jfolder.common.UnexpectedSystemException;
015: import org.jfolder.common.entity.InitializeSystemEntityTagContext;
016: import org.jfolder.common.entity.properties.SystemEntityPropertiesUpdates;
017: import org.jfolder.common.tagging.AppraiseConceptTagContext;
018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
019: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
020: import org.jfolder.common.tagging.ConceptTagConstraint;
021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
022: import org.jfolder.common.tagging.InitializeConceptTagContext;
023: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
024: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
025: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
026:
027: //other classes
028:
029: public class SystemEntityPropertiesUpdatesTag implements
030: SystemEntityPropertiesUpdates {
031:
032: //
033: private ConceptTagCharacteristic versionCtchar = null;
034: private ConceptTagCharacteristic documentCtchar = null;
035: private ConceptTagCharacteristic documentLengthCtchar = null;
036: private ConceptTagCharacteristic propertyTypeCtchar = null;
037: private ConceptTagCharacteristic propertyNameCtchar = null;
038: private ConceptTagCharacteristic propertyValueCtchar = null;
039:
040: //
041: //version details
042: private final static String VERSION_CTCON = "version";
043: private final static String VERSION_TITLE = "Version";
044: private final static String VERSION_SHORT_DESCRIPTION = "Version";
045:
046: //document details
047: private final static String DOCUMENT_CTCON = "document";
048: private final static String DOCUMENT_TITLE = "Document";
049: private final static String DOCUMENT_SHORT_DESCRIPTION = "Document";
050:
051: //document-length details
052: private final static String DOCUMENT_LENGTH_CTCON = "document-length";
053: private final static String DOCUMENT_LENGTH_TITLE = "Document Length";
054: private final static String DOCUMENT_LENGTH_SHORT_DESCRIPTION = "Document Length";
055:
056: //property-type details
057: private final static String PROPERTY_TYPE_CTCON = "property-type";
058: private final static String PROPERTY_TYPE_TITLE = "Property Type";
059: private final static String PROPERTY_TYPE_SHORT_DESCRIPTION = "Property Type";
060:
061: //property-name details
062: private final static String PROPERTY_NAME_CTCON = "property-name";
063: private final static String PROPERTY_NAME_TITLE = "Property Name";
064: private final static String PROPERTY_NAME_SHORT_DESCRIPTION = "Property Name";
065:
066: //property-value details
067: private final static String PROPERTY_VALUE_CTCON = "property-value";
068: private final static String PROPERTY_VALUE_TITLE = "Property Value";
069: private final static String PROPERTY_VALUE_SHORT_DESCRIPTION = "Property Value";
070:
071: //
072: public SystemEntityPropertiesUpdatesTag() {
073: }
074:
075: protected final static SystemEntityPropertiesUpdatesTag newInstance(
076: ConceptTagCharacteristic inCtchar, int inIndex,
077: int inVersion, int inDocLength, String inDoc,
078: ArrayList inPropTypes, ArrayList inPropNames,
079: ArrayList inPropValues) {
080:
081: SystemEntityPropertiesUpdatesTag outValue = new SystemEntityPropertiesUpdatesTag();
082:
083: ConceptTagCharacteristicHolder ctcharh = inCtchar.addValue(
084: inIndex, outValue, true);
085:
086: InitializeSystemEntityTagContext isetc = new InitializeSystemEntityTagContext(
087: ctcharh);
088:
089: outValue.initialize(isetc);
090:
091: //
092: outValue.versionCtchar.addValue(0, inVersion + "");
093: outValue.documentLengthCtchar.addValue(0, inDocLength + "");
094: if (inDoc != null) {
095: outValue.documentCtchar.addValue(0, inDoc);
096: }
097: for (int i = 0; i < inPropTypes.size(); i++) {
098: String nextType = (String) inPropTypes.get(i);
099: String nextName = (String) inPropNames.get(i);
100: String nextValue = (String) inPropValues.get(i);
101: //
102: outValue.propertyTypeCtchar.addValue(0, nextType);
103: outValue.propertyNameCtchar.addValue(0, nextName);
104: outValue.propertyValueCtchar.addValue(0, nextValue);
105: }
106:
107: return outValue;
108: }
109:
110: //
111: public void initialize(InitializeConceptTagContext inIctc) {
112:
113: //
114: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
115: .newInstance(inIctc);
116:
117: //constrain "version"
118: ConceptTagConstraint versionCtcon = ConceptTagConstraint
119: .newInstance(VERSION_CTCON, rootCtconh);
120: versionCtcon.setTitle(VERSION_TITLE);
121: versionCtcon.setShortDescription(VERSION_SHORT_DESCRIPTION);
122: //
123: StaticConceptTagConstraintContext versionSctcc = StaticConceptTagConstraintContext
124: .newInstance(versionCtcon);
125:
126: //constrain "document-length"
127: ConceptTagConstraint documentLengthCtcon = ConceptTagConstraint
128: .newInstance(DOCUMENT_LENGTH_CTCON, rootCtconh);
129: documentLengthCtcon.setTitle(DOCUMENT_LENGTH_TITLE);
130: documentLengthCtcon
131: .setShortDescription(DOCUMENT_LENGTH_SHORT_DESCRIPTION);
132: //
133: StaticConceptTagConstraintContext documentLengthSctcc = StaticConceptTagConstraintContext
134: .newInstance(documentLengthCtcon);
135:
136: //constrain "document"
137: ConceptTagConstraint documentCtcon = ConceptTagConstraint
138: .newInstance(DOCUMENT_CTCON, rootCtconh);
139: documentCtcon.setTitle(DOCUMENT_TITLE);
140: documentCtcon.setShortDescription(DOCUMENT_SHORT_DESCRIPTION);
141: //
142: StaticConceptTagConstraintContext documentSctcc = StaticConceptTagConstraintContext
143: .newInstance(documentCtcon);
144:
145: //constrain "property-type"
146: ConceptTagConstraint propertyTypeCtcon = ConceptTagConstraint
147: .newInstance(PROPERTY_TYPE_CTCON, rootCtconh);
148: propertyTypeCtcon.setTitle(PROPERTY_TYPE_TITLE);
149: propertyTypeCtcon
150: .setShortDescription(PROPERTY_TYPE_SHORT_DESCRIPTION);
151: //
152: StaticConceptTagConstraintContext propertyTypeSctcc = StaticConceptTagConstraintContext
153: .newInstance(propertyTypeCtcon);
154:
155: //constrain "property-name"
156: ConceptTagConstraint propertyNameCtcon = ConceptTagConstraint
157: .newInstance(PROPERTY_NAME_CTCON, rootCtconh);
158: propertyNameCtcon.setTitle(PROPERTY_NAME_TITLE);
159: propertyNameCtcon
160: .setShortDescription(PROPERTY_NAME_SHORT_DESCRIPTION);
161: //
162: StaticConceptTagConstraintContext propertyNameSctcc = StaticConceptTagConstraintContext
163: .newInstance(propertyNameCtcon);
164:
165: //constrain "property-value"
166: ConceptTagConstraint propertyValueCtcon = ConceptTagConstraint
167: .newInstance(PROPERTY_VALUE_CTCON, rootCtconh);
168: propertyValueCtcon.setTitle(PROPERTY_VALUE_TITLE);
169: propertyValueCtcon
170: .setShortDescription(PROPERTY_VALUE_SHORT_DESCRIPTION);
171: //
172: StaticConceptTagConstraintContext propertyValueSctcc = StaticConceptTagConstraintContext
173: .newInstance(propertyValueCtcon);
174:
175: //
176: inIctc.initialize();
177:
178: //
179: this .versionCtchar = versionCtcon.getCharacteristic();
180: this .documentCtchar = documentCtcon.getCharacteristic();
181: this .documentLengthCtchar = documentLengthCtcon
182: .getCharacteristic();
183: this .propertyTypeCtchar = propertyTypeCtcon.getCharacteristic();
184: this .propertyNameCtchar = propertyNameCtcon.getCharacteristic();
185: this .propertyValueCtchar = propertyValueCtcon
186: .getCharacteristic();
187: }
188:
189: public void appraise(AppraiseConceptTagContext inCtic) {
190: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
191: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
192: sctiic.setInstanceTitle("System Entity Properties Updates");
193: sctiic
194: .setInstanceDescription("System Entity Properties Updates");
195: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
196: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
197: scttic.setTypeTitle("System Entity Properties Updates");
198: scttic
199: .setTypeDescription("System Entity Properties Updates");
200: }
201: }
202:
203: //
204: //public String getName() {
205: //
206: // String outValue = null;
207: //
208: // if (this.nameCtchar.getValueLength() > 0) {
209: // outValue = this.nameCtchar.getValueAsString(0);
210: // }
211: // else {
212: // throw UnexpectedSystemException.unknownState();
213: // }
214: //
215: // return outValue;
216: //}
217: //protected void setName(String inName) {
218: //
219: // if (this.nameCtchar.getValueLength() > 0) {
220: // this.nameCtchar.replaceValueAndRemoveLocalFiles(0, inName);
221: // }
222: // else {
223: // this.nameCtchar.addValue(0, inName);
224: // }
225: //}
226:
227: //
228: public int getVersion() {
229:
230: int outValue = 0;
231:
232: if (this .versionCtchar.getValueLength() > 0) {
233: String value = this .versionCtchar.getValueAsString(0, null);
234: outValue = Integer.parseInt(value);
235: }
236:
237: return outValue;
238: }
239:
240: public int getDocLength() {
241:
242: int outValue = 0;
243:
244: if (this .documentLengthCtchar.getValueLength() > 0) {
245: String value = this .documentLengthCtchar.getValueAsString(
246: 0, null);
247: outValue = Integer.parseInt(value);
248: }
249:
250: return outValue;
251: }
252:
253: public boolean isDocPresent() {
254: return (this .documentCtchar.getValueLength() > 0);
255: }
256:
257: public String getDoc() {
258:
259: String outValue = null;
260:
261: if (isDocPresent()) {
262: outValue = this .documentCtchar.getValueAsString(0, null);
263: }
264:
265: return outValue;
266: }
267:
268: //
269: public int getInstanceCount() {
270: return this .propertyTypeCtchar.getValueLength();
271: }
272:
273: public int getInstanceType(int inIndex) {
274:
275: int outValue = 0;
276:
277: if (this .propertyTypeCtchar.getValueLength() > 0) {
278: String value = this .propertyTypeCtchar.getValueAsString(
279: inIndex, null);
280: outValue = Integer.parseInt(value);
281: }
282:
283: return outValue;
284: }
285:
286: public String getInstanceName(int inIndex) {
287: return this .propertyNameCtchar.getValueAsString(inIndex, null);
288: }
289:
290: public String getInstanceValue(int inIndex) {
291: return this.propertyValueCtchar.getValueAsString(inIndex, null);
292: }
293: }
|