+/**\r
+* Copyright (C) 2011 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
package eu.etaxonomy.taxeditor.ui.section.userecords;\r
\r
import java.util.ArrayList;\r
import java.util.ListIterator;\r
import java.util.Map;\r
import java.util.Set;\r
-import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.events.SelectionListener;\r
\r
-import eu.etaxonomy.cdm.api.service.ITermService;\r
+import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
import eu.etaxonomy.cdm.model.common.Language;\r
import eu.etaxonomy.cdm.model.common.LanguageString;\r
import eu.etaxonomy.cdm.model.common.Marker;\r
+import eu.etaxonomy.cdm.model.common.TermType;\r
import eu.etaxonomy.cdm.model.description.CategoricalData;\r
-import eu.etaxonomy.cdm.model.description.Modifier;\r
import eu.etaxonomy.cdm.model.description.State;\r
import eu.etaxonomy.cdm.model.description.StateData;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
import eu.etaxonomy.taxeditor.store.TermStore;\r
+import eu.etaxonomy.taxeditor.store.UsageTermCollection;\r
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;\r
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
/**\r
* The context manager mediates context start/stop and workbench shutdowns to all registered listeners.\r
*\r
- * @author a.theys \r
+ * @author a.theys\r
* @created mar 13, 2012\r
* @version 1.0\r
*/\r
public class UseRecordDetailElement extends\r
AbstractCdmDetailElement<CategoricalData> implements SelectionListener {\r
\r
- private static final Logger logger = Logger\r
- .getLogger(UseRecordDetailElement.class);\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = Logger.getLogger(UseRecordDetailElement.class);\r
\r
private TermComboElement<State> combo_UseCategory;\r
private TermComboElement<State> combo_UseSubCategory;\r
- private TermComboElement<Modifier> combo_PlantPart;\r
- private TermComboElement<Modifier> combo_Country;\r
- private TermComboElement<Modifier> combo_HumanGroup;\r
- private TermComboElement<Modifier> combo_EthnicGroup;\r
+ private TermComboElement<DefinedTerm> combo_PlantPart;\r
+ private TermComboElement<DefinedTerm> combo_Country;\r
+ private TermComboElement<DefinedTerm> combo_HumanGroup;\r
+ private TermComboElement<DefinedTerm> combo_EthnicGroup;\r
\r
public UseRecordDetailElement(CdmFormFactory formFactory,\r
ICdmFormElement formElement) {\r
protected void createControls(ICdmFormElement formElement,\r
CategoricalData entity, int style) {\r
\r
- combo_UseCategory = formFactory.createTermComboElement(State.class, this, "Use Category", null, style);\r
+ combo_UseCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useCategoryVocabularyLabel, null, style);\r
combo_UseCategory.addSelectionListener(this);\r
- combo_UseSubCategory = formFactory.createTermComboElement(State.class, this, "Use SubCategory", null, style);\r
- combo_PlantPart = formFactory.createTermComboElement(Modifier.class, this, "Plant Part", null, style);\r
- combo_HumanGroup = formFactory.createTermComboElement(Modifier.class, this, "Human Group", null, style);\r
+ combo_UseSubCategory = formFactory.createDefinedTermComboElement(TermType.State, this, UsageTermCollection.useSubCategoryVocabularyLabel, null, style);\r
+ combo_PlantPart = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.plantPartLabel, null, style);\r
+ combo_HumanGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.humanGroupLabel, null, style);\r
combo_HumanGroup.addSelectionListener(this);\r
- combo_EthnicGroup = formFactory.createTermComboElement(Modifier.class, this, "Ethnic Group", null, style);\r
- combo_Country = formFactory.createTermComboElement(Modifier.class, this, "Country", null, style);\r
- \r
+ combo_EthnicGroup = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.ethnicGroupLabel, null, style);\r
+ combo_Country = formFactory.createDefinedTermComboElement(TermType.Modifier, this, UsageTermCollection.countryLabel, null, style);\r
+\r
\r
List<State> termsUseCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false));\r
combo_UseCategory.setTerms(termsUseCategory);\r
- combo_UseCategory.setSelection(stateSelection("Use Category"));\r
- \r
+ combo_UseCategory.setSelection(stateSelection(UsageTermCollection.useCategoryVocabularyLabel));\r
+\r
List<State> termsSubCategory = setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false), combo_UseCategory.getSelection());\r
- \r
+\r
if (termsSubCategory != null) {\r
combo_UseSubCategory.setTerms(termsSubCategory);\r
- combo_UseSubCategory.setSelection(stateSelection("Use SubCategory"));\r
+ combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));\r
combo_UseSubCategory.setEnabled(true);\r
}\r
else {\r
combo_UseSubCategory.setEnabled(false);\r
}\r
- \r
- List<Modifier> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), "Plant Part");\r
+\r
+ List<DefinedTerm> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.plantPartLabel);\r
combo_PlantPart.setTerms(plantPartsToAdd);\r
- combo_PlantPart.setSelection(modifierSelection("Plant Part"));\r
- \r
- List<Modifier> countriesToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), "Country");\r
+ combo_PlantPart.setSelection(modifierSelection(UsageTermCollection.plantPartLabel));\r
+\r
+ List<DefinedTerm> countriesToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.countryLabel);\r
combo_Country.setTerms(countriesToAdd);\r
- combo_Country.setSelection(modifierSelection("Country"));\r
- \r
- List<Modifier> humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(Modifier.class, null, false), "Human Group");\r
+ combo_Country.setSelection(modifierSelection(UsageTermCollection.countryLabel));\r
+\r
+ List<DefinedTerm> humanGroupToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.humanGroupLabel);\r
combo_HumanGroup.setTerms(humanGroupToAdd);\r
- combo_HumanGroup.setSelection(modifierSelection("Human Group"));\r
- \r
- List<Modifier> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), combo_HumanGroup.getSelection());\r
+ combo_HumanGroup.setSelection(modifierSelection(UsageTermCollection.humanGroupLabel));\r
+\r
+ List<DefinedTerm> ethnicGroupToAdd = setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), combo_HumanGroup.getSelection());\r
if (ethnicGroupToAdd != null) {\r
combo_EthnicGroup.setTerms(ethnicGroupToAdd);\r
- combo_EthnicGroup.setSelection(modifierSelection("Ethnic Group"));\r
+ combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));\r
combo_EthnicGroup.setEnabled(true);\r
} else {\r
combo_EthnicGroup.setEnabled(false);\r
\r
}\r
\r
- private Modifier modifierSelection(String comboCategory) {\r
- Modifier returnModifier = null;\r
+ /**\r
+ * Returns the select modifier\r
+ * @param comboCategory\r
+ * @return\r
+ */\r
+ private DefinedTerm modifierSelection(String comboCategory) {\r
if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
+ for (DefinedTerm modifier : getEntity().getModifiers()) {\r
if(GetVocabularyType(modifier, comboCategory)) {\r
- returnModifier = modifier;\r
+ return modifier;\r
}\r
}\r
- } \r
- \r
- if (returnModifier == null) {\r
- if (comboCategory == "Country") {\r
- returnModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("761dddee-bfa2-41f4-82df-3a19c71adee0")); \r
- } else if (comboCategory == "Plant Part") {\r
- returnModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("30150a82-a12f-4278-96ad-7ce708efa082")); \r
- } else if (comboCategory == "Human Group") {\r
- returnModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("c4b63327-2548-429d-8d55-81fdba5900a5")); \r
- } else if (comboCategory == "Ethnic Group") {\r
- returnModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("3ca851e5-d0d4-41cd-9066-f79e246c36c2")); \r
- }\r
+ } else {\r
+ return null;\r
}\r
- \r
- \r
- return returnModifier;\r
- \r
+ return null;\r
+\r
}\r
- \r
+\r
+ /**\r
+ * Returns the selected state\r
+ * @param comboCategory\r
+ * @return\r
+ */\r
private State stateSelection(String comboCategory) {\r
- State returnState = null;\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData statedata : getEntity().getStates()) {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData statedata : getEntity().getStateData()) {\r
if (statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
String testString = statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText();\r
if(testString.equals(comboCategory)) {\r
if(statedata.getState() !=null) {\r
- returnState = statedata.getState();\r
+ return statedata.getState();\r
}\r
}\r
- } \r
+ }\r
}\r
}\r
- \r
- if (returnState == null) {\r
- if (comboCategory == "Use Category") {\r
- returnState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("983a7184-6a51-489e-aca1-f21fc4fdbae3"));\r
- \r
- } else if (comboCategory == "Use SubCategory") {\r
- returnState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
- }\r
+ else {\r
+ return null;\r
}\r
- \r
- return returnState;\r
+ return null;\r
+\r
}\r
- \r
- private List<Modifier> setModifierComboTerms(List<Modifier> listOfTerms, String modType) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
- for (Modifier term : listOfTerms) {\r
+\r
+ /**\r
+ * This function sets the combo terms (Besides EthnicGroup\r
+ * @param listOfTerms\r
+ * @param modType\r
+ * @return\r
+ */\r
+ private List<DefinedTerm> setModifierComboTerms(List<DefinedTerm> listOfTerms, String modType) {\r
+ List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\r
+ for (DefinedTerm term : listOfTerms) {\r
\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modType))) {\r
termsToAdd.add(term);\r
termsToAdd.add(term);\r
}\r
}\r
- \r
+\r
return termsToAdd;\r
}\r
- \r
\r
\r
+ /**\r
+ * This function sets the Use Category combo term\r
+ * @param listOfTerms\r
+ * @return\r
+ */\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms) {\r
List<State> termsToAdd = new ArrayList<State>();\r
for (State term : listOfTerms) {\r
\r
- if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals("Use Category"))) {\r
+ if ((term.getPartOf() != null) && (term.getPartOf().getUuid().equals( UsageTermCollection.uuidUseCategoryVocabulary))) {\r
termsToAdd.add(term);\r
}\r
- else if ((term.getVocabulary() !=null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals("Use Category"))) {\r
+ else if ((term.getVocabulary() !=null) && (term.getPartOf() == null) && (term.getVocabulary().getUuid().equals(UsageTermCollection.uuidUseCategoryVocabulary))) {\r
termsToAdd.add(term);\r
}\r
}\r
\r
}\r
\r
+ /**\r
+ * This function sets the Use SubCategory combo term\r
+ * @param listOfTerms\r
+ * @param selectedUseCategory\r
+ * @return\r
+ */\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms,\r
State selectedUseCategory) {\r
List<State> termsToAdd = new ArrayList<State>();\r
if (combo_UseCategory.getSelection() != null) {\r
- \r
+\r
for (State term : listOfTerms) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {\r
termsToAdd.add(term);\r
else if ((term.getVocabulary() !=null) && (term.getVocabulary().getTitleCache().equals(selectedUseCategory.getTitleCache()))) {\r
termsToAdd.add(term);\r
}\r
- \r
+\r
}\r
}\r
- else if (!getEntity().getStates().isEmpty()) {\r
- for (StateData stateData : getEntity().getStates()) {\r
+ else if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData stateData : getEntity().getStateData()) {\r
if (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
- if ((stateData.getState() != null) && (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == "Use Category")) {\r
+ if ((stateData.getState() != null) && (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == UsageTermCollection.useCategoryVocabularyLabel)) {\r
for (State term : listOfTerms) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(stateData.getState().getTitleCache()))) {\r
termsToAdd.add(term);\r
termsToAdd.add(term);\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
- \r
+\r
}\r
- \r
+\r
else {\r
return null;\r
}\r
\r
return termsToAdd;\r
}\r
- \r
- private List<Modifier> setEthnicGroupComboTerms(List<Modifier> listOfTerms,\r
- Modifier selectedHumangroup) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
+\r
+\r
+ /**\r
+ * This function sets the EthnicGroup combo term\r
+ * @param listOfTerms\r
+ * @param selectedHumangroup\r
+ * @return\r
+ */\r
+ private List<DefinedTerm> setEthnicGroupComboTerms(List<DefinedTerm> listOfTerms,\r
+ DefinedTerm selectedHumangroup) {\r
+ List<DefinedTerm> termsToAdd = new ArrayList<DefinedTerm>();\r
if (combo_HumanGroup.getSelection() != null) {\r
- for (Modifier term : listOfTerms) {\r
- \r
+ for (DefinedTerm term : listOfTerms) {\r
+\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(selectedHumangroup.getTitleCache()))) {\r
termsToAdd.add(term);\r
}\r
}\r
}\r
else if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
+ for (DefinedTerm modifier : getEntity().getModifiers()) {\r
if (modifier.getMarkers() != null) {\r
for (Marker marker : modifier.getMarkers()) {\r
- if(marker.getMarkerType().getTitleCache().equals("Human Group")) {\r
- for (Modifier term : listOfTerms) {\r
+ if(marker.getMarkerType().getTitleCache().equals(UsageTermCollection.humanGroupLabel)) {\r
+ for (DefinedTerm term : listOfTerms) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modifier.getTitleCache()))) {\r
termsToAdd.add(modifier);\r
} else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals(modifier.getTitleCache()))) {\r
termsToAdd.add(modifier);\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
} else {\r
return null;\r
}\r
- \r
+\r
return termsToAdd;\r
}\r
\r
+\r
/** {@inheritDoc} */\r
@Override\r
public void handleEvent(Object eventSource) {\r
if (combo_UseCategory.getSelection() != null) {\r
boolean isChanged = false;\r
boolean isUseCategoryChanged = false;\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData useCategoryStateDataCheck : getEntity().getStates()) {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData useCategoryStateDataCheck : getEntity().getStateData()) {\r
Map<Language, LanguageString> modText = useCategoryStateDataCheck.getModifyingText();\r
- if(modText.get(CdmStore.getDefaultLanguage()) != null && modText.get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) {\r
+ if(modText.get(CdmStore.getDefaultLanguage()) != null && modText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useCategoryVocabularyLabel)) {\r
if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {\r
isUseCategoryChanged = true;\r
}\r
- \r
+\r
}\r
}\r
- ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator();\r
+ ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();\r
while(itrExistingStates.hasNext()) {\r
StateData existingStateData = itrExistingStates.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
.getModifyingText();\r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
- if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use Category")) {\r
+ if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useCategoryVocabularyLabel)) {\r
isChanged = true;\r
if(!existingStateData.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {\r
itrExistingStates.remove();\r
StateData stateData = StateData.NewInstance(combo_UseCategory.getSelection());\r
stateData.setState(combo_UseCategory.getSelection());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use Category");\r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(),UsageTermCollection.useCategoryVocabularyLabel);\r
itrExistingStates.add(stateData);\r
- \r
+\r
}\r
- } else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use SubCategory") && isUseCategoryChanged == true) {\r
+ } else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel) && isUseCategoryChanged == true) {\r
itrExistingStates.remove();\r
- State naUseSubCatState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
- StateData subCatStateData = StateData.NewInstance(naUseSubCatState);\r
- subCatStateData.setState(naUseSubCatState);\r
- subCatStateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(subCatStateData);\r
}\r
}\r
}\r
}\r
- \r
- \r
+\r
+\r
if (isChanged == false) {\r
StateData stateData = StateData\r
.NewInstance(combo_UseCategory.getSelection());\r
stateData.setState(combo_UseCategory.getSelection());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");\r
- getEntity().addState(stateData);\r
- State naUseSubCatState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
- StateData subCatStateData = StateData.NewInstance(naUseSubCatState);\r
- subCatStateData.setState(naUseSubCatState);\r
- subCatStateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(subCatStateData);\r
- \r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useCategoryVocabularyLabel);\r
+ getEntity().addStateData(stateData);\r
}\r
- \r
- State naUseSubCatState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
+\r
combo_UseSubCategory.setEnabled(true);\r
- combo_UseSubCategory.setSelection(naUseSubCatState);\r
- \r
+\r
}\r
else {\r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itr = getEntity().getStates().iterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itr = getEntity().getStateData().iterator();\r
while(itr.hasNext()) {\r
StateData stateToRemove = itr.next();\r
itr.remove();\r
}\r
- State naUseCatState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("983a7184-6a51-489e-aca1-f21fc4fdbae3"));\r
- StateData stateData = StateData.NewInstance(naUseCatState);\r
- stateData.setState(naUseCatState);\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");\r
- getEntity().addState(stateData);\r
List<State> termsSubCategory = new ArrayList<State>();\r
- State naUseSubCatState = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
- StateData subCatStateData = StateData.NewInstance(naUseSubCatState);\r
- subCatStateData.setState(naUseSubCatState);\r
- subCatStateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(subCatStateData);\r
- termsSubCategory.add(naUseSubCatState);\r
- \r
+ State emptyState = State.NewInstance();\r
+ termsSubCategory.add(emptyState);\r
combo_UseSubCategory.setTerms(termsSubCategory);\r
combo_UseSubCategory.setEnabled(false);\r
- } \r
+ }\r
}\r
}\r
- \r
+\r
if (eventSource == combo_UseSubCategory) {\r
if (combo_UseSubCategory.getSelection() != null) {\r
boolean isChanged = false;\r
- if (!getEntity().getStates().isEmpty()) {\r
- ListIterator<StateData> itrExistingStates = getEntity().getStates().listIterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ ListIterator<StateData> itrExistingStates = getEntity().getStateData().listIterator();\r
while(itrExistingStates.hasNext()) {\r
StateData existingStateData = itrExistingStates.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
.getModifyingText();\r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
- if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals("Use SubCategory")) {\r
+ if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel)) {\r
isChanged = true;\r
if(!existingStateData.getState().getTitleCache().equals(combo_UseSubCategory.getSelection().getTitleCache())) {\r
itrExistingStates.remove();\r
StateData stateData = StateData.NewInstance(combo_UseSubCategory.getSelection());\r
stateData.setState(combo_UseSubCategory.getSelection());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use SubCategory");\r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(),UsageTermCollection.useSubCategoryVocabularyLabel);\r
itrExistingStates.add(stateData);\r
}\r
}\r
}\r
}\r
}\r
- \r
+\r
if (isChanged == false){\r
StateData stateData = StateData\r
.NewInstance(combo_UseSubCategory.getSelection());\r
stateData.setState(combo_UseSubCategory.getSelection());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(stateData);\r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);\r
+ getEntity().addStateData(stateData);\r
}\r
- \r
+\r
} else {\r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itrStateData = getEntity().getStates().iterator();\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itrStateData = getEntity().getStateData().iterator();\r
while(itrStateData.hasNext()) {\r
StateData existingStateData = itrStateData.next();\r
Map<Language, LanguageString> modifyingText = existingStateData\r
.getModifyingText();\r
\r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
- if (modifyingText.get(CdmStore.getDefaultLanguage()).getText() == "Use SubCategory") {\r
+ if (modifyingText.get(CdmStore.getDefaultLanguage()).getText() == UsageTermCollection.useSubCategoryVocabularyLabel) {\r
itrStateData.remove();\r
}\r
}\r
}\r
}\r
- State naUseSubCat = (State) CdmStore.getService(ITermService.class).find(UUID.fromString("a8d80223-5c79-4063-8c6b-4dc8681e9c62"));\r
- StateData stateData = StateData.NewInstance(naUseSubCat);\r
- stateData.setState(naUseSubCat);\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(stateData);\r
- \r
}\r
}\r
if (eventSource == combo_PlantPart) {\r
if (combo_PlantPart.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
- if(GetVocabularyType(modifier, "Plant Part")) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
- Modifier plantPart = combo_PlantPart.getSelection();\r
+\r
+ }\r
+ DefinedTerm plantPart = combo_PlantPart.getSelection();\r
getEntity().addModifier(plantPart);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
- if(GetVocabularyType(currentMod, "Plant Part")) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.plantPartLabel)) {\r
itr.remove();\r
}\r
}\r
}\r
- Modifier naPlantPartModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("30150a82-a12f-4278-96ad-7ce708efa082"));\r
- getEntity().addModifier(naPlantPartModifier);\r
- \r
+\r
}\r
}\r
if (eventSource == combo_Country) {\r
if (combo_Country.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
- if(GetVocabularyType(modifier, "Country")) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {\r
itrExistingModifiers.remove();\r
}\r
- \r
+\r
}\r
- Modifier country = combo_Country.getSelection();\r
+ DefinedTerm country = combo_Country.getSelection();\r
getEntity().addModifier(country);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
- if(GetVocabularyType(currentMod, "Country")) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.countryLabel)) {\r
itr.remove();\r
}\r
}\r
}\r
- Modifier naCountryModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("761dddee-bfa2-41f4-82df-3a19c71adee0"));\r
- getEntity().addModifier(naCountryModifier);\r
}\r
}\r
if (eventSource == combo_HumanGroup) {\r
- Modifier naHumanGroupModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("c4b63327-2548-429d-8d55-81fdba5900a5"));\r
- Modifier naEthnicGroupModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("3ca851e5-d0d4-41cd-9066-f79e246c36c2"));\r
if (combo_HumanGroup.getSelection() != null) {\r
boolean isHumanGroupChanged = true;\r
- for (Modifier modToCheck: getEntity().getModifiers()) {\r
- if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, "Human Group"))) {\r
+ for (DefinedTerm modToCheck: getEntity().getModifiers()) {\r
+ if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) {\r
isHumanGroupChanged = false;\r
}\r
- \r
- \r
+\r
+\r
}\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
- if((GetVocabularyType(modifier, "Human Group") || GetVocabularyType(modifier, "Ethnic Group")) && isHumanGroupChanged) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
+\r
+ }\r
if(isHumanGroupChanged){\r
- Modifier humanGroup = combo_HumanGroup.getSelection();\r
+ DefinedTerm humanGroup = combo_HumanGroup.getSelection();\r
getEntity().addModifier(humanGroup);\r
- getEntity().addModifier(naEthnicGroupModifier);\r
- \r
}\r
- \r
combo_EthnicGroup.setEnabled(true);\r
- combo_EthnicGroup.setSelection(naEthnicGroupModifier);\r
- \r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- Iterator<Modifier> itr = modifiers.iterator();\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
- if(GetVocabularyType(currentMod, "Human Group") || GetVocabularyType(currentMod, "Ethnic Group")) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.humanGroupLabel) || GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
itr.remove();\r
}\r
}\r
}\r
- getEntity().addModifier(naHumanGroupModifier);\r
- getEntity().addModifier(naEthnicGroupModifier);\r
- List<Modifier> emptyListToResetComboBox = new ArrayList<Modifier>();\r
- emptyListToResetComboBox.add(naEthnicGroupModifier);\r
+ List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();\r
+\r
+// DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
+ DefinedTerm emptyMod = null;\r
+\r
+\r
+ emptyListToResetComboBox.add(emptyMod);\r
combo_EthnicGroup.setTerms(emptyListToResetComboBox);\r
- combo_EthnicGroup.setSelection(naEthnicGroupModifier);\r
combo_EthnicGroup.setEnabled(false);\r
- \r
+\r
}\r
}\r
if (eventSource == combo_EthnicGroup) {\r
if (combo_EthnicGroup.getSelection() != null) {\r
- Iterator<Modifier> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
while (itrExistingModifiers.hasNext()) {\r
- Modifier modifier = itrExistingModifiers.next();\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {\r
itrExistingModifiers.remove();\r
}\r
- \r
- } \r
- Modifier ethnicGroup = combo_EthnicGroup.getSelection();\r
+\r
+ }\r
+ DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();\r
getEntity().addModifier(ethnicGroup);\r
} else {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- \r
- Iterator<Modifier> itr = modifiers.iterator();\r
+\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
while (itr.hasNext()) {\r
- Modifier currentMod = itr.next();\r
- if(GetVocabularyType(currentMod, "Ethnic Group")) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
itr.remove();\r
}\r
}\r
- \r
+\r
}\r
- Modifier naEthnicGroupModifier = (Modifier) CdmStore.getService(ITermService.class).find(UUID.fromString("3ca851e5-d0d4-41cd-9066-f79e246c36c2"));\r
- getEntity().addModifier(naEthnicGroupModifier);\r
}\r
}\r
}\r
- \r
- \r
\r
- private boolean GetVocabularyType(Modifier term, String vocabularyExpected) {\r
+\r
+\r
+ /**\r
+ * This function Checks the vocabulary type\r
+ * @param term\r
+ * @param vocabularyExpected\r
+ * @return\r
+ */\r
+ private boolean GetVocabularyType(DefinedTerm term, String vocabularyExpected) {\r
if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(vocabularyExpected))) {\r
return true;\r
}\r
else if ((term.getVocabulary() != null) && (term.getPartOf()==null) && (term.getVocabulary().getTitleCache().equals(vocabularyExpected))) {\r
return true;\r
}\r
- else if ((vocabularyExpected.equals("Ethnic Group")) && (term.getVocabulary() != null) && ((term.getPartOf() != null))) {\r
+ else if ((vocabularyExpected.equals(UsageTermCollection.ethnicGroupLabel)) && ((term.getPartOf() != null))) {\r
return true;\r
}\r
return false;\r
}\r
- \r
- \r
+\r
+\r
\r
/** {@inheritDoc} */\r
@Override\r
super.setEntity(entity);\r
}\r
\r
+ /** {@inheritDoc} */\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
Object eventSource = e.getSource();\r
State selectedUseCategory = combo_UseCategory.getSelection();\r
if (selectedUseCategory != null) {\r
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));\r
- if (!getEntity().getStates().isEmpty()) {\r
- Iterator<StateData> itrExistingState = getEntity().getStates().iterator();\r
+\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itrExistingState = getEntity().getStateData().iterator();\r
while(itrExistingState.hasNext()) {\r
- StateData existingStateData = (StateData) itrExistingState.next();\r
+ StateData existingStateData = itrExistingState.next();\r
Map<Language, LanguageString> modifyingText = existingStateData.getModifyingText();\r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
if (modifyingText.get(CdmStore.getDefaultLanguage())\r
- .getText().equals("Use SubCategory")) {\r
- combo_UseSubCategory.setSelection(stateSelection("Use SubCategory"));\r
+ .getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel)) {\r
+ combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));\r
}\r
}\r
}\r
}\r
for (Object object: combo_HumanGroup.getControls()) {\r
if (object == eventSource) {\r
- Modifier selectedHumanGroup = combo_HumanGroup.getSelection();\r
+ DefinedTerm selectedHumanGroup = combo_HumanGroup.getSelection();\r
if (selectedHumanGroup != null) {\r
- combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup));\r
+ combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), selectedHumanGroup));\r
if (!getEntity().getModifiers().isEmpty()) {\r
- Iterator<Modifier> iterModifiers = getEntity().getModifiers().iterator();\r
+ Iterator<DefinedTerm> iterModifiers = getEntity().getModifiers().iterator();\r
while (iterModifiers.hasNext()) {\r
- Modifier existingModifier = iterModifiers.next();\r
- if(GetVocabularyType(existingModifier, "Ethnic Group")) {\r
- combo_EthnicGroup.setSelection(modifierSelection("Ethnic Group"));\r
+ DefinedTerm existingModifier = iterModifiers.next();\r
+ if(GetVocabularyType(existingModifier, UsageTermCollection.ethnicGroupLabel)) {\r
+ combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));\r
}\r
}\r
}\r
- \r
+\r
}\r
}\r
}\r
}\r
\r
+ /** {@inheritDoc} */\r
@Override\r
public void widgetDefaultSelected(SelectionEvent e) {\r
// TODO Auto-generated method stub\r