Source Code Cross Referenced for SystemEntityPropertiesTag.java in  » Workflow-Engines » JFolder » org » jfolder » common » entity » properties » v1 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » JFolder » org.jfolder.common.entity.properties.v1 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.io.IOException;
012:        import java.util.ArrayList;
013:        import java.util.Collections;
014:        import java.util.HashMap;
015:        import java.util.HashSet;
016:        import java.util.Iterator;
017:        import javax.xml.parsers.ParserConfigurationException;
018:        import org.xml.sax.SAXException;
019:
020:        //project specific classes
021:        import org.jfolder.common.UnexpectedSystemException;
022:        import org.jfolder.common.entity.InitializeSystemEntityTagContext;
023:        import org.jfolder.common.entity.SystemEntity;
024:        import org.jfolder.common.entity.SystemEntityUpdates;
025:        import org.jfolder.common.entity.SystemEntityUpdatesContext;
026:        import org.jfolder.common.entity.properties.SystemEntityProperties;
027:        import org.jfolder.common.tagging.AppraiseConceptTagContext;
028:        import org.jfolder.common.tagging.CompoundConceptTagConstraintContext;
029:        import org.jfolder.common.tagging.ConceptTag;
030:        import org.jfolder.common.tagging.ConceptTagCharacteristic;
031:        import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
032:        import org.jfolder.common.tagging.ConceptTagConstraint;
033:        import org.jfolder.common.tagging.ConceptTagConstraintHolder;
034:        import org.jfolder.common.tagging.ConceptTagConstraintTemplate;
035:        import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
036:        import org.jfolder.common.tagging.InitializeConceptTagContext;
037:        import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
038:        import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
039:        import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
040:        import org.jfolder.common.utils.misc.MiscHelper;
041:        import org.jfolder.common.utils.xml.XMLHelper;
042:
043:        //other classes
044:
045:        public class SystemEntityPropertiesTag implements 
046:                SystemEntityProperties {
047:
048:            //
049:            private final static String VALID_PROPERTY_NAME = ".*";
050:            private final static String VALID_PROPERTY_VALUE = ".*";
051:
052:            //
053:            private ConceptTagCharacteristic versionCtchar = null;
054:            private ConceptTagCharacteristic documentCtchar = null;
055:            private ConceptTagCharacteristic propertyCtchar = null;
056:            private ConceptTagCharacteristic deletedPropertyNameCtchar = null;
057:            //
058:            private String currentDocument = null;
059:            //
060:            private String originalDocument = null;
061:            //
062:            private HashMap currentPropNamesMap = null;
063:            private HashMap currentPropValuesMap = null;
064:            private HashMap currentDeletedPropNamesMap = null;
065:            //
066:            private HashMap originalPropNamesMap = null;
067:            private HashMap originalPropValuesMap = null;
068:            private HashMap originalDeletedPropNamesMap = null;
069:
070:            //
071:            //version details
072:            private final static String VERSION_CTCON = "version";
073:            private final static String VERSION_TITLE = "Version";
074:            private final static String VERSION_SHORT_DESCRIPTION = "Version";
075:
076:            //document details
077:            private final static String DOCUMENT_CTCON = "document";
078:            private final static String DOCUMENT_TITLE = "Document";
079:            private final static String DOCUMENT_SHORT_DESCRIPTION = "Document";
080:
081:            //property details
082:            private final static String PROPERTY_CTCON = "property";
083:            private final static String PROPERTY_TITLE = "Property";
084:            private final static String PROPERTY_SHORT_DESCRIPTION = "Property";
085:            //type of property details
086:            private final static String PROPERTY_CTCON_NAME_CTCTEMP = "name";
087:            private final static String PROPERTY_CTCON_NAME_TITLE = "Name";
088:            private final static String PROPERTY_CTCON_NAME_SHORT_DESCRIPTION = "Name";
089:            //value of property details
090:            private final static String PROPERTY_CTCON_VALUE_CTCTEMP = "value";
091:            private final static String PROPERTY_CTCON_VALUE_TITLE = "Value";
092:            private final static String PROPERTY_CTCON_VALUE_SHORT_DESCRIPTION = "Value";
093:
094:            //deleted-property-name details
095:            private final static String DELETED_PROPERTY_NAME_CTCON = "deleted-property-name";
096:            private final static String DELETED_PROPERTY_NAME_TITLE = "Deleted Property Name";
097:            private final static String DELETED_PROPERTY_NAME_SHORT_DESCRIPTION = "Deleted Property Name";
098:
099:            //
100:            public SystemEntityPropertiesTag() {
101:            }
102:
103:            public final static SystemEntityPropertiesTag newInstance(
104:                    ConceptTagCharacteristic inCtchar, int inIndex,
105:                    String inPropDoc, int inVersion, HashMap inPropNames,
106:                    HashMap inPropValues, HashMap inDeletedPropNames) {
107:
108:                //
109:                SystemEntityPropertiesTag outValue = new SystemEntityPropertiesTag();
110:
111:                //
112:                //for (int i = 0; i < 100; i++) {
113:                //    MiscHelper.println("SysEntPropTag version = " + inVersion);
114:                //}
115:
116:                //
117:                ConceptTagCharacteristicHolder ctcharh = inCtchar.addValue(
118:                        inIndex, outValue, true);
119:
120:                InitializeSystemEntityTagContext isetc = new InitializeSystemEntityTagContext(
121:                        ctcharh);
122:
123:                outValue.initialize(isetc);
124:
125:                //
126:                outValue.versionCtchar.addValue(0, inVersion + "");
127:
128:                //
129:                outValue.documentCtchar.addValue(0, inPropDoc);
130:
131:                //
132:                ArrayList propertyNames = new ArrayList(inPropNames.keySet());
133:                for (int i = 0; i < propertyNames.size(); i++) {
134:                    String nextUpperName = (String) propertyNames.get(i);
135:                    String nextName = (String) inPropNames.get(nextUpperName);
136:                    String nextValue = (String) inPropValues.get(nextUpperName);
137:                    ConceptTagCharacteristic nextCtchar = outValue
138:                            .createPropertyCtchar(nextName);
139:                    if (nextValue != null) {
140:                        nextCtchar.addValue(0, nextValue);
141:                    }
142:                }
143:
144:                //
145:                ArrayList deletedPropertyNames = new ArrayList(
146:                        inDeletedPropNames.keySet());
147:                for (int i = 0; i < deletedPropertyNames.size(); i++) {
148:                    String nextUpperName = (String) deletedPropertyNames.get(i);
149:                    String nextName = (String) inDeletedPropNames
150:                            .get(nextUpperName);
151:                    outValue.deletedPropertyNameCtchar.addValue(0, nextName);
152:                }
153:
154:                //
155:                //outValue.nameCtchar.addValue(0, inName);
156:                outValue.loadOriginalState(true);
157:
158:                return outValue;
159:            }
160:
161:            private void loadOriginalState(boolean inResetOriginal) {
162:
163:                //
164:                this .currentDocument = getDocument();
165:                //
166:                if (inResetOriginal) {
167:                    this .originalDocument = getDocument();
168:                }
169:                //
170:                this .currentPropNamesMap = new HashMap();
171:                this .currentPropValuesMap = new HashMap();
172:                this .currentDeletedPropNamesMap = new HashMap();
173:
174:                //
175:                if (inResetOriginal) {
176:                    this .originalPropNamesMap = new HashMap();
177:                    this .originalPropValuesMap = new HashMap();
178:                    this .originalDeletedPropNamesMap = new HashMap();
179:                }
180:
181:                for (int i = 0; i < getPropertyCount(); i++) {
182:                    String nextName[] = new String[1];
183:                    String nextValue[] = new String[1];
184:                    getPropertyNameAndValue(i, nextName, nextValue);
185:                    //
186:                    this .currentPropNamesMap.put((nextName[0]).toUpperCase(),
187:                            nextName[0]);
188:                    this .currentPropValuesMap.put((nextName[0]).toUpperCase(),
189:                            nextValue[0]);
190:                    //
191:                    if (inResetOriginal) {
192:                        this .originalPropNamesMap.put((nextName[0])
193:                                .toUpperCase(), nextName[0]);
194:                        this .originalPropValuesMap.put((nextName[0])
195:                                .toUpperCase(), nextValue[0]);
196:                    }
197:                }
198:
199:                int length = this .deletedPropertyNameCtchar.getValueLength();
200:                for (int i = 0; i < length; i++) {
201:                    String nextNa = this .deletedPropertyNameCtchar
202:                            .getValueAsString(i, null);
203:                    //
204:                    this .currentDeletedPropNamesMap.put(nextNa.toUpperCase(),
205:                            nextNa);
206:                    //
207:                    if (inResetOriginal) {
208:                        this .originalDeletedPropNamesMap.put(nextNa
209:                                .toUpperCase(), nextNa);
210:                    }
211:                }
212:            }
213:
214:            //
215:            public void initialize(InitializeConceptTagContext inIctc) {
216:
217:                //
218:                ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
219:                        .newInstance(inIctc);
220:
221:                //constrain "version"
222:                ConceptTagConstraint versionCtcon = ConceptTagConstraint
223:                        .newInstance(VERSION_CTCON, rootCtconh);
224:                versionCtcon.setTitle(VERSION_TITLE);
225:                versionCtcon.setShortDescription(VERSION_SHORT_DESCRIPTION);
226:                //
227:                StaticConceptTagConstraintContext versionSctcc = StaticConceptTagConstraintContext
228:                        .newInstance(versionCtcon);
229:
230:                //constrain "document"
231:                ConceptTagConstraint documentCtcon = ConceptTagConstraint
232:                        .newInstance(DOCUMENT_CTCON, rootCtconh);
233:                documentCtcon.setTitle(DOCUMENT_TITLE);
234:                documentCtcon.setShortDescription(DOCUMENT_SHORT_DESCRIPTION);
235:                //
236:                StaticConceptTagConstraintContext documentSctcc = StaticConceptTagConstraintContext
237:                        .newInstance(documentCtcon);
238:
239:                //constrain "property"
240:                ConceptTagConstraint propertyCtcon = ConceptTagConstraint
241:                        .newInstance(PROPERTY_CTCON, rootCtconh);
242:                propertyCtcon.setMinimumLength(0);
243:                propertyCtcon.setLengthUnbounded(true);
244:                //
245:                CompoundConceptTagConstraintContext propertyCctcc = CompoundConceptTagConstraintContext
246:                        .newInstance(propertyCtcon);
247:                //
248:                //constrain "name" of "property"
249:                ConceptTagConstraintTemplate propertyCtconNameCtctemp = ConceptTagConstraintTemplate
250:                        .newInstance(PROPERTY_CTCON_NAME_CTCTEMP, propertyCctcc);
251:                propertyCtconNameCtctemp.setMinimumLength(1);
252:                propertyCtconNameCtctemp.setMaximumLength(1);
253:                //
254:                StaticConceptTagConstraintContext propertyCtconNameSctcc = StaticConceptTagConstraintContext
255:                        .newInstance(propertyCtconNameCtctemp);
256:                //
257:                //constrain "value" of "property"
258:                ConceptTagConstraintTemplate propertyCtconValueCtctemp = ConceptTagConstraintTemplate
259:                        .newInstance(PROPERTY_CTCON_VALUE_CTCTEMP,
260:                                propertyCctcc);
261:                propertyCtconValueCtctemp.setMinimumLength(1);
262:                propertyCtconValueCtctemp.setMaximumLength(1);
263:                //
264:                StaticConceptTagConstraintContext propertyCtconValueSctcc = StaticConceptTagConstraintContext
265:                        .newInstance(propertyCtconValueCtctemp);
266:                DynamicConceptTagConstraintContext propertyCtconValueDctcc = DynamicConceptTagConstraintContext
267:                        .newInstance(propertyCtconValueCtctemp);
268:
269:                //constrain "deleted-property-name"
270:                ConceptTagConstraint deletedPropertyNameCtcon = ConceptTagConstraint
271:                        .newInstance(DELETED_PROPERTY_NAME_CTCON, rootCtconh);
272:                deletedPropertyNameCtcon.setTitle(DELETED_PROPERTY_NAME_TITLE);
273:                deletedPropertyNameCtcon
274:                        .setShortDescription(DELETED_PROPERTY_NAME_SHORT_DESCRIPTION);
275:                //
276:                StaticConceptTagConstraintContext deletedPropertyNameSctcc = StaticConceptTagConstraintContext
277:                        .newInstance(deletedPropertyNameCtcon);
278:
279:                //
280:                inIctc.initialize();
281:
282:                //initialize characteristics
283:                this .versionCtchar = versionCtcon.getCharacteristic();
284:                this .documentCtchar = documentCtcon.getCharacteristic();
285:                this .propertyCtchar = propertyCtcon.getCharacteristic();
286:                this .deletedPropertyNameCtchar = deletedPropertyNameCtcon
287:                        .getCharacteristic();
288:            }
289:
290:            private ConceptTagCharacteristic createPropertyCtchar(String inName) {
291:
292:                ConceptTagCharacteristic outValue = null;
293:
294:                int nextIndex = this .propertyCtchar.getValueLength();
295:                ConceptTagCharacteristicHolder argumentCtcharh = this .propertyCtchar
296:                        .createRegisteredHolder(nextIndex, true);
297:                //
298:                ConceptTagCharacteristic nameCtchar = argumentCtcharh
299:                        .registerCharacteristic(PROPERTY_CTCON_NAME_CTCTEMP);
300:                nameCtchar.addValue(0, inName);
301:                //
302:                outValue = argumentCtcharh
303:                        .registerCharacteristic(PROPERTY_CTCON_VALUE_CTCTEMP);
304:                //
305:
306:                return outValue;
307:            }
308:
309:            public int getVersion() {
310:
311:                int outValue = 0;
312:
313:                if (this .versionCtchar.getValueLength() > 0) {
314:                    String value = this .versionCtchar.getValueAsString(0, null);
315:                    outValue = Integer.parseInt(value);
316:                }
317:
318:                return outValue;
319:            }
320:
321:            private void getPropertyNameAndValue(int inIndex, String inName[],
322:                    String inValue[]) {
323:
324:                //for (int i = 0; i < this.propertyCtchar.getValueLength(); i++) {
325:                ConceptTagCharacteristicHolder ctcharh = this .propertyCtchar
326:                        .getValueAsHolder(inIndex, null);
327:                //
328:                ConceptTagCharacteristic nameCtchar = ctcharh
329:                        .getCharacteristic(PROPERTY_CTCON_NAME_CTCTEMP);
330:                if (nameCtchar.getValueLength() > 0) {
331:                    inName[0] = nameCtchar.getValueAsString(0, null);
332:                } else {
333:                    inName[0] = null;
334:                }
335:                //
336:                ConceptTagCharacteristic valueCtchar = ctcharh
337:                        .getCharacteristic(PROPERTY_CTCON_VALUE_CTCTEMP);
338:                if (valueCtchar.getValueLength() > 0) {
339:                    inValue[0] = valueCtchar.getValueAsString(0, null);
340:                } else {
341:                    inValue[0] = null;
342:                }
343:                //}
344:            }
345:
346:            //
347:            public void appraise(AppraiseConceptTagContext inCtic) {
348:                if (inCtic instanceof  StudioConceptTagInstanceInfoContext) {
349:                    StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
350:                    sctiic.setInstanceTitle("System Entity Properties");
351:                    sctiic.setInstanceDescription("System Entity Properties");
352:                } else if (inCtic instanceof  StudioConceptTagTypeInfoContext) {
353:                    StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
354:                    scttic.setTypeTitle("System Entity Properties");
355:                    scttic.setTypeDescription("System Entity Properties");
356:                }
357:            }
358:
359:            //
360:            public int getPropertyCount() {
361:                return this .propertyCtchar.getValueLength();
362:            }
363:
364:            public String getPropertyValue(String inName) {
365:
366:                String outValue = null;
367:
368:                if (isPropertyPresent(inName)) {
369:                    String name[] = new String[1];
370:                    String value[] = new String[1];
371:                    //
372:                    for (int i = 0; i < getPropertyCount(); i++) {
373:                        //
374:                        getPropertyNameAndValue(i, name, value);
375:                        if (name[0] != null
376:                                && (name[0]).equalsIgnoreCase(inName)) {
377:                            if (value[0] != null) {
378:                                outValue = value[0];
379:                            }
380:                        }
381:                    }
382:                } else {
383:                    throw new UnexpectedSystemException("Property '" + inName
384:                            + "' does not exist");
385:                }
386:
387:                return outValue;
388:            }
389:
390:            //
391:            public void removeProperty(String inName) {
392:                if (isPropertyPresent(inName)) {
393:                    for (int i = 0; i < getPropertyCount(); i++) {
394:                        if (getPropertyName(i).equalsIgnoreCase(inName)) {
395:                            this .propertyCtchar.removeValueWithLocalFiles(i);
396:                            this .deletedPropertyNameCtchar.addValue(0, inName);
397:                        }
398:                    }
399:                } else {
400:                    throw new UnexpectedSystemException("Property '" + inName
401:                            + "' does not exist");
402:                }
403:            }
404:
405:            public String getPropertyName(int inIndex) {
406:
407:                String outValue = null;
408:
409:                if (inIndex < getPropertyCount()) {
410:                    String name[] = new String[1];
411:                    String value[] = new String[1];
412:                    getPropertyNameAndValue(inIndex, name, value);
413:                    outValue = name[0];
414:                } else {
415:                    throw new UnexpectedSystemException(
416:                            "No property at index '" + inIndex + "'");
417:                }
418:
419:                return outValue;
420:            }
421:
422:            public String getPropertyValue(int inIndex) {
423:
424:                String outValue = null;
425:
426:                if (inIndex < getPropertyCount()) {
427:                    String name[] = new String[1];
428:                    String value[] = new String[1];
429:                    getPropertyNameAndValue(inIndex, name, value);
430:                    outValue = value[0];
431:                } else {
432:                    throw new UnexpectedSystemException(
433:                            "No property at index '" + inIndex + "'");
434:                }
435:
436:                return outValue;
437:            }
438:
439:            //
440:            public boolean isPropertyPresent(String inName) {
441:
442:                boolean outValue = false;
443:
444:                for (int i = 0; i < getPropertyCount(); i++) {
445:                    String nextName = getPropertyName(i);
446:                    if (nextName.equalsIgnoreCase(inName)) {
447:                        outValue = true;
448:                    }
449:                }
450:
451:                return outValue;
452:            }
453:
454:            //
455:            public boolean isValidPropertyName(String inName) {
456:
457:                boolean outValue = false;
458:
459:                outValue = MiscHelper.isRegularExpressionMatch(inName,
460:                        VALID_PROPERTY_NAME, false);
461:
462:                return outValue;
463:            }
464:
465:            public boolean isValidPropertyValue(String inValue) {
466:
467:                boolean outValue = false;
468:
469:                outValue = MiscHelper.isRegularExpressionMatch(inValue,
470:                        VALID_PROPERTY_VALUE, false);
471:
472:                return outValue;
473:            }
474:
475:            //
476:            public void createProperty(String inName, String inValue) {
477:                if (!isPropertyPresent(inName)) {
478:                    ConceptTagCharacteristic valueCtchar = createPropertyCtchar(inName);
479:                    valueCtchar.addValue(0, inValue);
480:                    int delCount = this .deletedPropertyNameCtchar
481:                            .getValueLength();
482:                    for (int i = delCount - 1; i >= 0; i--) {
483:                        String nextDelName = this .deletedPropertyNameCtchar
484:                                .getValueAsString(i, null);
485:                        if (nextDelName.equalsIgnoreCase(inName)) {
486:                            this .deletedPropertyNameCtchar
487:                                    .removeValueWithLocalFiles(i);
488:                        }
489:                    }
490:                } else {
491:                    throw new UnexpectedSystemException("Property '" + inName
492:                            + "' already exists");
493:                }
494:            }
495:
496:            public void updateProperty(String inName, String inValue) {
497:                if (isPropertyPresent(inName)) {
498:                    for (int i = 0; i < getPropertyCount(); i++) {
499:                        ConceptTagCharacteristicHolder nextCtcharh = this .propertyCtchar
500:                                .getValueAsHolder(i, null);
501:                        //
502:                        ConceptTagCharacteristic nextNameCtchar = nextCtcharh
503:                                .getCharacteristic(PROPERTY_CTCON_NAME_CTCTEMP);
504:                        String nextName = nextNameCtchar.getValueAsString(0,
505:                                null);
506:                        if (nextName.equalsIgnoreCase(inName)) {
507:                            ConceptTagCharacteristic nextValueCtchar = nextCtcharh
508:                                    .getCharacteristic(PROPERTY_CTCON_VALUE_CTCTEMP);
509:                            nextValueCtchar.replaceValueAndRemoveLocalFiles(0,
510:                                    inValue);
511:                            break;
512:                        }
513:                    }
514:                } else {
515:                    throw new UnexpectedSystemException("Property '" + inName
516:                            + "' does not exist");
517:                }
518:            }
519:
520:            //
521:            public void setDocument(String inDocument) {
522:
523:                if (isValidDocument(inDocument)) {
524:                    if (this .documentCtchar.getValueLength() > 0) {
525:                        this .documentCtchar.replaceValueAndRemoveLocalFiles(0,
526:                                inDocument);
527:                    } else {
528:                        this .documentCtchar.addValue(0, inDocument);
529:                    }
530:                } else {
531:                    throw new UnexpectedSystemException(
532:                            "Not a valid document '" + inDocument + "'");
533:                }
534:            }
535:
536:            public String getDocument() {
537:
538:                String outValue = null;
539:
540:                if (this .documentCtchar.getValueLength() > 0) {
541:                    outValue = this .documentCtchar.getValueAsString(0, null);
542:                } else {
543:                }
544:
545:                return outValue;
546:            }
547:
548:            public boolean isValidDocument(String inDocument) {
549:
550:                boolean outValue = true;
551:
552:                try {
553:                    XMLHelper.loadDocument(inDocument);
554:                } catch (ParserConfigurationException pce) {
555:                    outValue = false;
556:                } catch (SAXException saxe) {
557:                    outValue = false;
558:                } catch (IOException ioe) {
559:                    outValue = false;
560:                }
561:
562:                return outValue;
563:            }
564:
565:            //
566:            public SystemEntityUpdates getSystemEntityUpdates(
567:                    SystemEntityUpdatesContext inSeuc) {
568:                //
569:
570:                SystemEntityPropertiesUpdatesTag outValue = null;
571:
572:                loadOriginalState(false);
573:
574:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
575:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
576:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
577:                MiscHelper.println(toString());
578:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
579:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
580:                MiscHelper.println("                ABOUT TO SAVE PROPERTIES");
581:
582:                //
583:                int version = (getVersion() + 1);
584:                int docLength = getDocument().length();
585:                //
586:                String docDiff = null;
587:                if (!this .currentDocument.equals(this .originalDocument)) {
588:                    docDiff = this .currentDocument;
589:                }
590:                //
591:                ArrayList propTypes = new ArrayList();
592:                ArrayList propNames = new ArrayList();
593:                ArrayList propValues = new ArrayList();
594:                //
595:                ArrayList currPropNames = new ArrayList(
596:                        this .currentPropNamesMap.keySet());
597:                for (int i = 0; i < currPropNames.size(); i++) {
598:                    String nextCurrUpperName = (String) currPropNames.get(i);
599:                    String nextCurrName = (String) this .currentPropNamesMap
600:                            .get(nextCurrUpperName);
601:                    String nextCurrValue = (String) this .currentPropValuesMap
602:                            .get(nextCurrUpperName);
603:                    //
604:                    //check for updates
605:                    if (this .originalPropNamesMap
606:                            .containsKey(nextCurrUpperName)) {
607:                        //
608:                        //
609:                        String nextOrigName = (String) this .originalPropNamesMap
610:                                .get(nextCurrUpperName);
611:                        String nextOrigValue = (String) this .originalPropValuesMap
612:                                .get(nextCurrUpperName);
613:                        //
614:                        if (!nextCurrValue.equals(nextOrigValue)
615:                                || !nextCurrName.equals(nextOrigName)) {
616:                            MiscHelper.println("SQLInstType = '" + "UPDATE"
617:                                    + "'");
618:                            MiscHelper.println("SQLInstName = '" + nextCurrName
619:                                    + "'");
620:                            MiscHelper.println("SQLInstValue= '"
621:                                    + nextCurrValue + "'");
622:                            propTypes.add(UPDATE_ENTITY + "");
623:                            propNames.add(nextCurrName);
624:                            propValues.add(nextCurrValue);
625:                        }
626:                    }
627:                    //
628:                    //check for creates
629:                    if (!this .originalPropNamesMap
630:                            .containsKey(nextCurrUpperName)
631:                            && !this .originalDeletedPropNamesMap
632:                                    .containsKey(nextCurrUpperName)) {
633:                        //
634:                        MiscHelper.println("SQLInstType = '" + "CREATE" + "'");
635:                        MiscHelper.println("SQLInstName = '" + nextCurrName
636:                                + "'");
637:                        MiscHelper.println("SQLInstValue= '" + nextCurrValue
638:                                + "'");
639:                        propTypes.add(CREATE_ENTITY + "");
640:                        propNames.add(nextCurrName);
641:                        propValues.add(nextCurrValue);
642:                    }
643:                    //
644:                    //check for revives
645:                    if (!this .originalPropNamesMap
646:                            .containsKey(nextCurrUpperName)
647:                            && this .originalDeletedPropNamesMap
648:                                    .containsKey(nextCurrUpperName)) {
649:                        //
650:                        MiscHelper.println("SQLInstType = '" + "UPDATE" + "'");
651:                        MiscHelper.println("SQLInstName = '" + nextCurrName
652:                                + "'");
653:                        MiscHelper.println("SQLInstValue= '" + nextCurrValue
654:                                + "'");
655:                        propTypes.add(UPDATE_ENTITY + "");
656:                        propNames.add(nextCurrName);
657:                        propValues.add(nextCurrValue);
658:                    }
659:                }
660:
661:                ArrayList removePropNames = new ArrayList(
662:                        this .currentDeletedPropNamesMap.keySet());
663:                MiscHelper
664:                        .println("SysEntPropUpdateTag this.currentDeletedPropNamesMap = "
665:                                + this .currentDeletedPropNamesMap);
666:                MiscHelper
667:                        .println("SysEntPropUpdateTag this.originalPropNamesMap = "
668:                                + this .originalPropNamesMap);
669:                MiscHelper.println("SysEntPropUpdateTag removePropNames = "
670:                        + removePropNames);
671:                for (int i = 0; i < removePropNames.size(); i++) {
672:                    String nextDeletedCurrUpperName = (String) removePropNames
673:                            .get(i);
674:                    String nextDeletedCurrName = (String) this .currentDeletedPropNamesMap
675:                            .get(nextDeletedCurrUpperName);
676:                    //
677:                    //check for deletes
678:                    if (this .originalPropNamesMap
679:                            .containsKey(nextDeletedCurrUpperName)
680:                            && this .currentDeletedPropNamesMap
681:                                    .containsKey(nextDeletedCurrUpperName)) {
682:                        //
683:                        //
684:                        MiscHelper.println("SQLInstType = '" + "DELETE" + "'");
685:                        MiscHelper.println("SQLInstName = '"
686:                                + nextDeletedCurrName + "'");
687:                        MiscHelper.println("SQLInstValue= '" + "" + "'");
688:                        propTypes.add(DELETE_ENTITY + "");
689:                        propNames.add(nextDeletedCurrName);
690:                        propValues.add("");
691:                    }
692:                }
693:
694:                loadOriginalState(true);
695:
696:                outValue = SystemEntityPropertiesUpdatesTag.newInstance(inSeuc
697:                        .getParentCharacteristic(), inSeuc
698:                        .getParentCharacteristicIndex(), version, docLength,
699:                        docDiff, propTypes, propNames, propValues);
700:
701:                if (inSeuc.isAlign()) {
702:                    this .versionCtchar.replaceValueAndRemoveLocalFiles(0,
703:                            ((getVersion() + 1) + ""));
704:                }
705:
706:                return outValue;
707:            }
708:
709:            public String toString() {
710:
711:                StringBuffer outValue = new StringBuffer();
712:
713:                outValue.append("  CURRENT PROPERTIES\n");
714:                ArrayList currPropNames = new ArrayList(
715:                        this .currentPropNamesMap.keySet());
716:                Collections.sort(currPropNames);
717:                for (int i = 0; i < currPropNames.size(); i++) {
718:                    String nextKey = (String) currPropNames.get(i);
719:                    String nextName = (String) this .currentPropNamesMap
720:                            .get(nextKey);
721:                    String nextValue = (String) this .currentPropValuesMap
722:                            .get(nextKey);
723:                    outValue.append("    '" + nextName + "' = '" + nextValue
724:                            + "'\n");
725:                }
726:                //
727:                outValue.append("  DELETED PROPERTIES\n");
728:                ArrayList delePropNames = new ArrayList(
729:                        this .currentDeletedPropNamesMap.keySet());
730:                Collections.sort(delePropNames);
731:                for (int i = 0; i < delePropNames.size(); i++) {
732:                    String nextKey = (String) delePropNames.get(i);
733:                    Object nextName = this .currentDeletedPropNamesMap
734:                            .get(nextKey);
735:                    outValue.append("    '" + nextName + "'\n");
736:                }
737:
738:                return outValue.toString();
739:            }
740:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.