001: /*
002: * Created on 13.05.2005
003: *
004: */
005: package org.openwfe.gpe.xml;
006:
007: import java.util.HashMap;
008: import java.util.Map;
009:
010: import org.eclipse.jface.dialogs.MessageDialog;
011: import org.openwfe.gpe.model.AndComposite;
012: import org.openwfe.gpe.model.CaseComposite;
013: import org.openwfe.gpe.model.ConcurrenceComposite;
014: import org.openwfe.gpe.model.ConcurrentIteratorElement;
015: import org.openwfe.gpe.model.DefinedComposite;
016: import org.openwfe.gpe.model.DefinedElement;
017: import org.openwfe.gpe.model.EqualsElement;
018: import org.openwfe.gpe.model.GreaterElement;
019: import org.openwfe.gpe.model.IfComposite;
020: import org.openwfe.gpe.model.IncElement;
021: import org.openwfe.gpe.model.IteratorElement;
022: import org.openwfe.gpe.model.LesserElement;
023: import org.openwfe.gpe.model.LogElement;
024: import org.openwfe.gpe.model.NotElement;
025: import org.openwfe.gpe.model.OrComposite;
026: import org.openwfe.gpe.model.ParticipantElement;
027: import org.openwfe.gpe.model.RestoreElement;
028: import org.openwfe.gpe.model.SaveElement;
029: import org.openwfe.gpe.model.SequenceComposite;
030: import org.openwfe.gpe.model.SetElement;
031: import org.openwfe.gpe.model.SubProcessElement;
032: import org.openwfe.gpe.model.UndefinedElement;
033: import org.openwfe.gpe.model.UnsetElement;
034: import org.openwfe.gpe.model.WhenComposite;
035:
036: /**
037: * @author Helena
038: * This class maps the XML element names with the model classes
039: */
040: public class Hashtable_Import {
041:
042: public Map map = new HashMap();
043:
044: public Hashtable_Import() {
045: map.put(DefinedComposite.name.toLowerCase(),
046: DefinedComposite.class);
047: map
048: .put(DefinedElement.name.toLowerCase(),
049: DefinedElement.class);
050: map.put(SetElement.name.toLowerCase(), SetElement.class);
051: map.put(UndefinedElement.name.toLowerCase(),
052: UndefinedElement.class);
053: map
054: .put(RestoreElement.name.toLowerCase(),
055: RestoreElement.class);
056: map.put(LesserElement.name.toLowerCase(), LesserElement.class);
057: map
058: .put(GreaterElement.name.toLowerCase(),
059: GreaterElement.class);
060: map.put(EqualsElement.name.toLowerCase(), EqualsElement.class);
061: map.put(SubProcessElement.name.toLowerCase(),
062: SubProcessElement.class);
063: map.put(LogElement.name.toLowerCase(), LogElement.class);
064: map.put(SaveElement.name.toLowerCase(), SaveElement.class);
065: map.put(IncElement.name.toLowerCase(), IncElement.class);
066: map.put(UnsetElement.name.toLowerCase(), UnsetElement.class);
067: map.put(ParticipantElement.name.toLowerCase(),
068: ParticipantElement.class);
069: map.put(NotElement.name.toLowerCase(), NotElement.class);
070: map.put(IteratorElement.name.toLowerCase(),
071: IteratorElement.class);
072: map.put(ConcurrentIteratorElement.name.toLowerCase(),
073: ConcurrentIteratorElement.class);
074: map.put(WhenComposite.name.toLowerCase(), WhenComposite.class);
075: map.put(IfComposite.name.toLowerCase(), IfComposite.class);
076: map.put(CaseComposite.name.toLowerCase(), CaseComposite.class);
077: map.put(SequenceComposite.name.toLowerCase(),
078: SequenceComposite.class);
079: map.put(OrComposite.name.toLowerCase(), OrComposite.class);
080: map.put(AndComposite.name.toLowerCase(), AndComposite.class);
081: map.put(ConcurrenceComposite.name.toLowerCase(),
082: ConcurrenceComposite.class);
083: //Sub process is deprecated but we still need to comply with older versions
084: map.put("subprocess-definition", DefinedComposite.class);
085:
086: }
087:
088: public Object findElement(String obj) {
089:
090: Object temp = map.get(obj);
091: //if the element the xml document does not exist we have an error message
092: if (temp == null) {
093: MessageDialog.openInformation(null, "Alert", "The element "
094: + obj + " is undefined.\n"
095: + "It will not be inserted in the workflow");
096: }
097: return temp;
098:
099: }
100: }
|