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.console.web.dictionary;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.tagging.BaseInitializeConceptTagContext;
014: import org.jfolder.common.tagging.ConceptTag;
015: import org.jfolder.common.tagging.ConceptTagCharacteristic;
016: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
017: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
018: import org.jfolder.common.tagging.ConceptTagPreferences;
019: import org.jfolder.common.tagging.ReturnableConceptTag;
020: import org.jfolder.common.tagging.RootConceptTagHolder;
021: import org.jfolder.common.tagging.SelectionCriteriaForConceptTag;
022: import org.jfolder.common.tagging.SelectionCriteriaForReturnableConceptTag;
023:
024: //other classes
025:
026: public class InspectorInitializeConceptTagContext extends
027: BaseInitializeConceptTagContext {
028:
029: //
030: private String example = null;
031: private SelectionCriteriaForConceptTag scfct = null;
032:
033: //
034:
035: private InspectorInitializeConceptTagContext(
036: ConceptTagPreferences inCtp) {
037: super (inCtp, null);
038: }
039:
040: private InspectorInitializeConceptTagContext(
041: ConceptTagCharacteristicHolder inCtcharh) {
042:
043: //
044: this (getPreferences(inCtcharh));
045:
046: ConceptTagConstraintHolder ctconh = createConstraintHolder(
047: getPreferences(inCtcharh), inCtcharh, null);
048:
049: this .setConstraintHolder(ctconh);
050: }
051:
052: protected final static InspectorInitializeConceptTagContext newInstance(
053: ConceptTagPreferences inCtp, ConceptTag inCt) {
054:
055: InspectorInitializeConceptTagContext outValue = null;
056:
057: RootConceptTagHolder localRcth = getEmptyRcth(inCtp);
058: // SystemEntityTagHelper.getGovernorCall();
059:
060: ConceptTagCharacteristicHolder ctcharh = localRcth
061: .getRootCharacteristicHolder();
062: //
063: ConceptTagCharacteristic ctchar = null;
064: if (inCtp.getRootConstraint().equals(
065: inCtp.getUnconstrainedSymbol())) {
066: ctchar = ctcharh.getUndefinedCharacteristic();
067: } else if (ctcharh.isCharacteristicPresent(inCtp
068: .getRootConstraint())) {
069: ctchar = ctcharh.getCharacteristic(inCtp
070: .getRootConstraint());
071: } else {
072: ctchar = ctcharh.registerCharacteristic(inCtp
073: .getRootConstraint());
074: }
075: ConceptTagCharacteristicHolder subCtcharh = ctchar.addValue(0,
076: inCt, false);
077: //
078: localRcth.validate();
079:
080: outValue = new InspectorInitializeConceptTagContext(subCtcharh);
081: outValue.setExample(localRcth.getXMLRepresentation(true));
082: outValue.setSelectionCriteria(getSelectionCriteria(inCt));
083: //if (inCt instanceof ReturnableConceptTag) {
084: //
085: //}
086: //else {
087: //}
088:
089: return outValue;
090: }
091:
092: //
093: protected String getExample() {
094: return this .example;
095: }
096:
097: private void setExample(String inExample) {
098: this .example = inExample;
099: }
100:
101: //
102: protected SelectionCriteriaForConceptTag getSelectionCriteria() {
103: return this .scfct;
104: }
105:
106: private void setSelectionCriteria(
107: SelectionCriteriaForConceptTag inScfct) {
108: this .scfct = inScfct;
109: }
110:
111: public void nonImmediateValidation() {
112: }
113:
114: public void initialize() {
115: //do nothing
116: }
117:
118: ////////////////////////////////////////
119: public ConceptTagConstraintHolder getConstraintHolder(
120: ConceptTag inCt) {
121: //
122: ConceptTagConstraintHolder outValue = getConstraintHolder();
123:
124: inCt.initialize(this);
125:
126: return outValue;
127: }
128: }
|