+/**\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.Iterator;\r
import java.util.List;\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.apache.logging.log4j.LogManager;\r
+import org.apache.logging.log4j.Logger;\r
import org.eclipse.swt.events.SelectionEvent;\r
import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.ui.forms.widgets.Section;\r
\r
-import eu.etaxonomy.cdm.api.service.IService;\r
-import eu.etaxonomy.cdm.api.service.IVocabularyService;\r
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
+import eu.etaxonomy.cdm.model.common.CdmBase;\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.MarkerType;\r
-import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.description.CategoricalData;\r
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\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.cdm.remote.controller.VocabularyController;\r
+import eu.etaxonomy.cdm.model.term.DefinedTerm;\r
+import eu.etaxonomy.cdm.model.term.TermType;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
-import eu.etaxonomy.taxeditor.store.TermManager;\r
import eu.etaxonomy.taxeditor.store.TermStore;\r
-import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;\r
+import eu.etaxonomy.taxeditor.store.UsageTermCollection;\r
+import eu.etaxonomy.taxeditor.ui.combo.term.TermComboElement;\r
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;\r
-import eu.etaxonomy.taxeditor.ui.element.CheckboxElement;\r
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;\r
-import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.EntityDetailType;\r
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;\r
-import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;\r
-import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;\r
-import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;\r
\r
-//public class UseRecordDetailElement extends AbstractDetailedDescriptionDetailElement<CategoricalData> {\r
+/**\r
+ * The context manager mediates context start/stop and workbench shutdowns to all registered listeners.\r
+ *\r
+ * @author a.theys\r
+ * @created mar 13, 2012\r
+ */\r
public class UseRecordDetailElement extends\r
AbstractCdmDetailElement<CategoricalData> implements SelectionListener {\r
\r
- private static final Logger logger = Logger\r
- .getLogger(DescriptionElementDetailElement.class);\r
+ @SuppressWarnings("unused")\r
+ private static final Logger logger = LogManager.getLogger();\r
\r
- // private CheckboxElement checkbox_orderRelevant;\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 AbstractDetailedDescriptionDetailElement detailElement;\r
-\r
- /*\r
- * public UseRecordDetailElement(CdmFormFactory formFactory, ICdmFormElement\r
- * formElement, CategoricalData entity, int style) { super(formFactory,\r
- * formElement, entity, style); }\r
- */\r
- /*\r
- * public UseRecordDetailElement(CdmFormFactory formFactory, ICdmFormElement\r
- * formElement, int style) {\r
- */\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
super(formFactory, formElement);\r
}\r
\r
- /** {@inheritDoc} */\r
@Override\r
protected void createControls(ICdmFormElement formElement,\r
CategoricalData entity, int style) {\r
\r
- // State state = State.NewInstance("Tato", "Toto", "Titi");\r
- // checkbox_orderRelevant = formFactory.createCheckbox(formElement,\r
- // "Order Relevant", entity.getOrderRelevant(), style);\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_Country = formFactory.createTermComboElement(Modifier.class, this, "Country", 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
- \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(useCategorySelection());\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
- \r
combo_UseSubCategory.setTerms(termsSubCategory);\r
- combo_UseSubCategory.setSelection(useSubCategorySelection());\r
+ combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));\r
combo_UseSubCategory.setEnabled(true);\r
}\r
else {\r
combo_UseSubCategory.setEnabled(false);\r
}\r
- List<Modifier> plantPartsToAdd = setPlantPartsComboTerms(TermStore.getTerms(Modifier.class, null, false));\r
+\r
+ List<DefinedTerm> plantPartsToAdd = setModifierComboTerms(TermStore.getTerms(DefinedTerm.class, null, false), UsageTermCollection.plantPartLabel);\r
combo_PlantPart.setTerms(plantPartsToAdd);\r
- combo_PlantPart.setSelection(plantPartSelection());\r
- \r
- List<Modifier> countriesToAdd = setCountryComboTerms(TermStore.getTerms(Modifier.class, null, false));\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(countrySelection());\r
- \r
- List<Modifier> humanGroupToAdd = setHumanGroupComboTerms(TermStore.getTerms(Modifier.class, null, false));\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(humanGroupSelection());\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(ethnicGroupSelection());\r
+ combo_EthnicGroup.setSelection(modifierSelection(UsageTermCollection.ethnicGroupLabel));\r
combo_EthnicGroup.setEnabled(true);\r
} else {\r
combo_EthnicGroup.setEnabled(false);\r
}\r
-\r
- // getPreferredTerms(State.class));\r
- // UseSubCategory_stateData =\r
- // formFactory.createTermComboElement(State.class, this,\r
- // "Use Sub Category", null , style);\r
- // createEntityDetailSection(EntityDetailType.USE_CAT,\r
- // getConversationHolder(), formElement, Section.EXPANDED);\r
- // UseSubCategory_stateData = (UseSubCategorySection)\r
- // formFactory.createEntityDetailSection(EntityDetailType.USE_SUBCAT,\r
- // getConversationHolder(), formElement,Section.EXPANDED);\r
- // UseCategory_stateData.setEntity(entity);\r
- // UseSubCategory_stateData.setEntity(entity);\r
- // UseCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2,\r
- // 1));\r
- // UseSubCategory_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2,\r
- // 1));\r
-\r
}\r
\r
- \r
- \r
- private Modifier plantPartSelection() {\r
- /*if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if(marker.getMarkerType().getTitleCache().equals("PlantPart")) {\r
- return modifier;\r
- }\r
- else {\r
- return null;\r
- }\r
- }\r
- }\r
- else {\r
- return null;\r
+ /**\r
+ * Returns the select modifier\r
+ */\r
+ private DefinedTerm modifierSelection(String comboCategory) {\r
+ if(!getEntity().getModifiers().isEmpty()) {\r
+ for (DefinedTerm modifier : getEntity().getModifiers()) {\r
+ if(GetVocabularyType(modifier, comboCategory)) {\r
+ return modifier;\r
}\r
- \r
}\r
} else {\r
return null;\r
}\r
- return null;*/\r
- //for testing purposes\r
- int countMods = 0;\r
- Modifier modiftoreturn = Modifier.NewInstance();\r
- if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()){\r
- if(countMods == 0) {\r
- modiftoreturn = modifier;\r
- }\r
- countMods++;\r
- }\r
- return modiftoreturn;\r
- }\r
- return null;\r
- \r
- }\r
- \r
- private Modifier countrySelection() {\r
- /*if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if(marker.getMarkerType().getTitleCache().equals("Country")) {\r
- return modifier;\r
- }\r
- else {\r
- return null;\r
- }\r
- }\r
- }\r
- else {\r
- return null;\r
- }\r
- \r
- }\r
- } else {\r
- return null;\r
- }\r
- return null;*/\r
- //for testing purposes\r
- int countMods = 0;\r
- Modifier modiftoreturn = Modifier.NewInstance();\r
- if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()){\r
- if(countMods == 1) {\r
- modiftoreturn = modifier;\r
- }\r
- countMods++;\r
- }\r
- return modiftoreturn;\r
- }\r
- return null;\r
- }\r
- \r
- private Modifier humanGroupSelection() {\r
- /*if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if(marker.getMarkerType().getTitleCache().equals("Human Group")) {\r
- return modifier;\r
- }\r
- else {\r
- return null;\r
- }\r
- }\r
- }\r
- else {\r
- return null;\r
- }\r
- \r
- }\r
- } else {\r
return null;\r
}\r
- return null;*/\r
- //for testing purposes\r
- int countMods =0;\r
- Modifier modiftoreturn = Modifier.NewInstance();\r
- if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()){\r
- if (countMods == 2) {\r
- modiftoreturn = modifier;\r
- }\r
- countMods++;\r
- }\r
- return modiftoreturn;\r
- }\r
- return null;\r
- }\r
- \r
- private Modifier ethnicGroupSelection() {\r
- /*if(!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if(marker.getMarkerType().getTitleCache().equals("Human Group")) {\r
- return modifier;\r
- }\r
- else {\r
- return null;\r
- }\r
- }\r
- }\r
- else {\r
- return null;\r
- }\r
- \r
- }\r
- } else {\r
- return null;\r
- }\r
- return null;*/\r
- //for testing purposes\r
- int countMods =0;\r
- Modifier modiftoreturn = Modifier.NewInstance();\r
- if (!getEntity().getModifiers().isEmpty()) {\r
- for (Modifier modifier : getEntity().getModifiers()){\r
- if (countMods == 3) {\r
- modiftoreturn = modifier;\r
- }\r
- countMods++;\r
- }\r
- return modiftoreturn;\r
- }\r
- return null;\r
- }\r
\r
- private State useCategorySelection() {\r
- /*if (!getEntity().getStates().isEmpty()) {\r
- for (StateData statedata : getEntity().getStates()) {\r
+ /**\r
+ * Returns the selected state\r
+ */\r
+ private State stateSelection(String comboCategory) {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ for (StateData statedata : getEntity().getStateData()) {\r
if (statedata.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
- if(statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == "Use Category") {\r
+ String testString = statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText();\r
+ if(testString.equals(comboCategory)) {\r
if(statedata.getState() !=null) {\r
- return statedata.getState();\r
+ return CdmBase.deproxy(statedata.getState(), State.class);\r
}\r
}\r
- } \r
- }\r
- }\r
- else {\r
- return null;\r
- }\r
- return null;*/\r
- //for testing purposes\r
- int countStates =0;\r
- for (StateData state : getEntity().getStates()) {\r
- if (countStates == 0) {\r
- return state.getState();\r
- }\r
- countStates++;\r
- }\r
- return null;\r
- }\r
- \r
-\r
- \r
- private State useSubCategorySelection() {\r
- /*if (!getEntity().getStates().isEmpty() && combo_UseCategory.getSelection() != null) {\r
- for (StateData statedata : getEntity().getStates()) {\r
- if (stateData.getModifyingText().get(CdmStore.getDefaultLanguage()) != null) {\r
- if(statedata.getModifyingText().get(CdmStore.getDefaultLanguage()).getText() == "Use SubCategory") {\r
- if(statedata.getState() !=null) {\r
- return statedata.getState();\r
- }\r
- \r
- }\r
- } \r
+ }\r
}\r
}\r
else {\r
return null;\r
}\r
- return null;*/\r
- //for testing purposes\r
- int countStates =0;\r
- for (StateData state : getEntity().getStates()) {\r
- if ((countStates == 1)) {\r
- return state.getState();\r
- }\r
- countStates++;\r
- }\r
return null;\r
- \r
}\r
\r
- private List<Modifier> setPlantPartsComboTerms(List<Modifier> listOfTerms) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
- for (Modifier term : listOfTerms) {\r
+ /**\r
+ * This function sets the combo terms (Besides EthnicGroup\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("Plant Part"))) {\r
+ if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals(modType))) {\r
termsToAdd.add(term);\r
}\r
- else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals("Plant Part"))) {\r
+ else if ((term.getVocabulary() != null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals(modType))) {\r
termsToAdd.add(term);\r
}\r
}\r
- \r
- return termsToAdd;\r
- }\r
- \r
- private List<Modifier> setCountryComboTerms(List <Modifier> listOfTerms) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
- for (Modifier term : listOfTerms) {\r
\r
- if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals("Country"))) {\r
- termsToAdd.add(term);\r
- }\r
- else if ((term.getVocabulary() != null) && (term.getVocabulary().getTitleCache().equals("Country"))) {\r
- termsToAdd.add(term);\r
- }\r
- }\r
- \r
return termsToAdd;\r
}\r
\r
-\r
+ /**\r
+ * This function sets the Use Category combo term\r
+ */\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms) {\r
- List<State> termsToAdd = new ArrayList<State>();\r
+ List<State> termsToAdd = new ArrayList<>();\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
return termsToAdd;\r
-\r
}\r
\r
+ /**\r
+ * This function sets the Use SubCategory combo term\r
+ */\r
private List<State> setUseCategoryComboTerms(List<State> listOfTerms,\r
State selectedUseCategory) {\r
- List<State> termsToAdd = new ArrayList<State>();\r
+\r
+ List<State> termsToAdd = new ArrayList<>();\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
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
+ */\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
- return termsToAdd;\r
- }\r
-\r
- \r
- private List<Modifier> setHumanGroupComboTerms(List<Modifier> listOfTerms) {\r
- List<Modifier> termsToAdd = new ArrayList<Modifier>();\r
- for (Modifier term : listOfTerms) {\r
\r
- if ((term.getPartOf() != null) && (term.getPartOf().getTitleCache().equals("Human Group"))) {\r
- termsToAdd.add(term);\r
- }\r
- else if ((term.getVocabulary() != null) && (term.getPartOf() == null) && (term.getVocabulary().getTitleCache().equals("Human Group"))) {\r
- termsToAdd.add(term);\r
- }\r
- }\r
- \r
return termsToAdd;\r
}\r
\r
-\r
- /** {@inheritDoc} */\r
@Override\r
public void handleEvent(Object eventSource) {\r
- /*\r
- * if(eventSource == checkbox_orderRelevant){\r
- * getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection());\r
- * }\r
- */\r
if (eventSource == combo_UseCategory) {\r
if (combo_UseCategory.getSelection() != null) {\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData existingStateData : getEntity().getStates()) {\r
+ boolean isChanged = false;\r
+ boolean isUseCategoryChanged = false;\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(UsageTermCollection.useCategoryVocabularyLabel)) {\r
+ if(!useCategoryStateDataCheck.getState().getTitleCache().equals(combo_UseCategory.getSelection().getTitleCache())) {\r
+ isUseCategoryChanged = true;\r
+ }\r
+\r
+ }\r
+ }\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
- \r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
- if (modifyingText.get(CdmStore.getDefaultLanguage())\r
- .getText() == "Use Category") {\r
- getEntity().removeState(existingStateData);\r
- StateData stateData = StateData.NewInstance(combo_UseCategory.getSelection());\r
- stateData.setState(combo_UseCategory.getSelection());\r
- //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use Category");\r
- getEntity().addState(stateData);\r
- } else {\r
- StateData stateData = StateData\r
- .NewInstance(combo_UseCategory.getSelection());\r
- stateData.setState(combo_UseCategory.getSelection());\r
- //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use Category");\r
- getEntity().addState(stateData);\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(),UsageTermCollection.useCategoryVocabularyLabel);\r
+ itrExistingStates.add(stateData);\r
+\r
+ }\r
+ } else if (modifyingText.get(CdmStore.getDefaultLanguage()).getText().equals(UsageTermCollection.useSubCategoryVocabularyLabel) && isUseCategoryChanged == true) {\r
+ itrExistingStates.remove();\r
}\r
- \r
- } else {\r
- StateData stateData = StateData\r
- .NewInstance(combo_UseCategory.getSelection());\r
- stateData.setState(combo_UseCategory.getSelection());\r
- //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");\r
- getEntity().addState(stateData);\r
}\r
}\r
}\r
- else {\r
+\r
+ if (isChanged == false) {\r
StateData stateData = StateData\r
.NewInstance(combo_UseCategory.getSelection());\r
stateData.setState(combo_UseCategory.getSelection());\r
- //stateData.addModifyingText("Use Category", CdmStore.getDefaultLanguage());\r
- //LanguageString languageString = LanguageString.NewInstance("Use Category", CdmStore.getDefaultLanguage());\r
- //IService object = (IService) CdmStore.getCurrentApplicationConfiguration().getBean(IService.class.getName());\r
- //object.save(languageString);\r
- stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use Category");\r
- getEntity().addState(stateData);\r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useCategoryVocabularyLabel);\r
+ getEntity().addStateData(stateData);\r
}\r
+\r
combo_UseSubCategory.setEnabled(true);\r
- \r
+ }\r
+ else {\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itr = getEntity().getStateData().iterator();\r
+ while(itr.hasNext()) {\r
+ itr.next();\r
+ itr.remove();\r
+ }\r
+ List<State> termsSubCategory = new ArrayList<>();\r
+ State emptyState = State.NewInstance();\r
+ termsSubCategory.add(emptyState);\r
+ combo_UseSubCategory.setTerms(termsSubCategory);\r
+ combo_UseSubCategory.setEnabled(false);\r
+ }\r
}\r
}\r
+\r
if (eventSource == combo_UseSubCategory) {\r
if (combo_UseSubCategory.getSelection() != null) {\r
- if (!getEntity().getStates().isEmpty()) {\r
- for (StateData existingStateData : getEntity().getStates()) {\r
+ boolean isChanged = false;\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
- \r
if (modifyingText.get(CdmStore.getDefaultLanguage()) != null) {\r
- if (modifyingText.get(CdmStore.getDefaultLanguage())\r
- .getText() == "Use SubCategory") {\r
- getEntity().removeState(existingStateData);\r
- StateData stateData = StateData.NewInstance(combo_UseSubCategory.getSelection());\r
- stateData.setState(combo_UseSubCategory.getSelection());\r
- //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());\r
- //stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use SubCategory");\r
- getEntity().addState(stateData);\r
- } else {\r
- StateData stateData = StateData\r
- .NewInstance(combo_UseSubCategory.getSelection());\r
- stateData.setState(combo_UseSubCategory.getSelection());\r
- //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());\r
- //stateData.putModifyingText(CdmStore.getDefaultLanguage(),"Use SubCategory");\r
- getEntity().addState(stateData);\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(),UsageTermCollection.useSubCategoryVocabularyLabel);\r
+ itrExistingStates.add(stateData);\r
+ }\r
}\r
- \r
- } else {\r
- StateData stateData = StateData\r
- .NewInstance(combo_UseSubCategory.getSelection());\r
- stateData.setState(combo_UseSubCategory.getSelection());\r
- //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());\r
- //stateData.putModifyingText(CdmStore.getDefaultLanguage(), "Use SubCategory");\r
- getEntity().addState(stateData);\r
}\r
}\r
}\r
- else {\r
+\r
+ if (isChanged == false){\r
StateData stateData = StateData\r
.NewInstance(combo_UseSubCategory.getSelection());\r
stateData.setState(combo_UseSubCategory.getSelection());\r
- //stateData.addModifyingText("Use SubCategory", CdmStore.getDefaultLanguage());\r
- //LanguageString languageString = LanguageString.NewInstance("Use SubCategory", CdmStore.getDefaultLanguage());\r
- //IService object = (IService) CdmStore.getCurrentApplicationConfiguration().getBean(IService.class.getName());\r
- //object.save(languageString);\r
- //stateData.putModifyingText(languageString);\r
- getEntity().addState(stateData);\r
+ stateData.putModifyingText(CdmStore.getDefaultLanguage(), UsageTermCollection.useSubCategoryVocabularyLabel);\r
+ getEntity().addStateData(stateData);\r
+ }\r
+ } else {\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() == UsageTermCollection.useSubCategoryVocabularyLabel) {\r
+ itrStateData.remove();\r
+ }\r
+ }\r
+ }\r
}\r
- \r
}\r
}\r
if (eventSource == combo_PlantPart) {\r
if (combo_PlantPart.getSelection() != null) {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ while (itrExistingModifiers.hasNext()) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if(GetVocabularyType(modifier, UsageTermCollection.plantPartLabel)) {\r
+ itrExistingModifiers.remove();\r
+ }\r
+ }\r
+ DefinedTerm plantPart = combo_PlantPart.getSelection();\r
+ getEntity().addModifier(plantPart);\r
+ } else {\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- for (Modifier modifier : modifiers) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if (marker.getMarkerType().getTitleCache().equals("PlantPart")) {\r
- getEntity().removeModifier(modifier);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);\r
- //getEntity().addModifier(combo_PlantPart.getSelection());\r
- } \r
- else {\r
- MarkerType markerType = MarkerType.NewInstance("PlantPart", "PlantPart", null);\r
- Marker markerPlantPart = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(markerPlantPart);\r
- getEntity().addModifier(plantPart);\r
- //getEntity().addModifier(combo_PlantPart.getSelection());\r
- }\r
- \r
- \r
- }\r
- \r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
+ while (itr.hasNext()) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.plantPartLabel)) {\r
+ itr.remove();\r
}\r
- else {\r
- MarkerType markerType = MarkerType.NewInstance("PlantPart", "PlantPart", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);\r
- //getEntity().addModifier(combo_PlantPart.getSelection());\r
- }\r
- \r
- } \r
- }\r
- else {\r
- MarkerType markerType = MarkerType.NewInstance("PlantPart", "PlantPart", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);\r
- //getEntity().addModifier(combo_PlantPart.getSelection());\r
+ }\r
}\r
}\r
}\r
if (eventSource == combo_Country) {\r
if (combo_Country.getSelection() != null) {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ while (itrExistingModifiers.hasNext()) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if(GetVocabularyType(modifier, UsageTermCollection.countryLabel)) {\r
+ itrExistingModifiers.remove();\r
+ }\r
+ }\r
+ DefinedTerm country = combo_Country.getSelection();\r
+ getEntity().addModifier(country);\r
+ } else {\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- for (Modifier modifier : modifiers) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if (marker.getMarkerType().getTitleCache().equals("Country")) {\r
- /*getEntity().removeModifier(modifier);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_Country.getSelection());\r
- } \r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Country", "Country", null);\r
- Marker markerPlantPart = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(markerPlantPart);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_Country.getSelection());\r
- }\r
- \r
- \r
- }\r
- \r
- }\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Country", "Country", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_Country.getSelection());\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
+ while (itr.hasNext()) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.countryLabel)) {\r
+ itr.remove();\r
}\r
- \r
- } \r
- }\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Country", "Country", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_Country.getSelection());\r
+ }\r
}\r
}\r
}\r
if (eventSource == combo_HumanGroup) {\r
if (combo_HumanGroup.getSelection() != null) {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
+ boolean isHumanGroupChanged = true;\r
+ for (DefinedTerm modToCheck: getEntity().getModifiers()) {\r
+ if(modToCheck.equals(combo_HumanGroup.getSelection()) && (GetVocabularyType(modToCheck, UsageTermCollection.humanGroupLabel))) {\r
+ isHumanGroupChanged = false;\r
+ }\r
+ }\r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ while (itrExistingModifiers.hasNext()) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if((GetVocabularyType(modifier, UsageTermCollection.humanGroupLabel) || GetVocabularyType(modifier, UsageTermCollection.ethnicGroupLabel)) && isHumanGroupChanged) {\r
+ itrExistingModifiers.remove();\r
+ }\r
+ }\r
+ if(isHumanGroupChanged){\r
+ DefinedTerm humanGroup = combo_HumanGroup.getSelection();\r
+ getEntity().addModifier(humanGroup);\r
+ }\r
+ combo_EthnicGroup.setEnabled(true);\r
+ } else {\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
if(!modifiers.isEmpty()) {\r
- for (Modifier modifier : modifiers) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if (marker.getMarkerType().getTitleCache().equals("Human Group")) {\r
- /*getEntity().removeModifier(modifier);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_HumanGroup.getSelection());\r
- } \r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Human Group", "Human Group", null);\r
- Marker markerPlantPart = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(markerPlantPart);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_HumanGroup.getSelection());\r
- }\r
- \r
- \r
- }\r
- \r
- }\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Human Group", "Human Group", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_HumanGroup.getSelection());\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
+ while (itr.hasNext()) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.humanGroupLabel) || GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
+ itr.remove();\r
}\r
- \r
- } \r
- }\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Human Group", "Human Group", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_HumanGroup.getSelection());\r
+ }\r
}\r
+ List<DefinedTerm> emptyListToResetComboBox = new ArrayList<DefinedTerm>();\r
+\r
+// DefinedTerm emptyMod = DefinedTerm.NewInstance();\r
+ DefinedTerm emptyMod = null;\r
+\r
+ emptyListToResetComboBox.add(emptyMod);\r
+ combo_EthnicGroup.setTerms(emptyListToResetComboBox);\r
+ combo_EthnicGroup.setEnabled(false);\r
}\r
- combo_EthnicGroup.setEnabled(true);\r
}\r
if (eventSource == combo_EthnicGroup) {\r
if (combo_EthnicGroup.getSelection() != null) {\r
- Set<Modifier> modifiers = getEntity().getModifiers();\r
- if(!modifiers.isEmpty()) {\r
- for (Modifier modifier : modifiers) {\r
- if (modifier.getMarkers() != null) {\r
- for (Marker marker : modifier.getMarkers()) {\r
- if (marker.getMarkerType().getTitleCache().equals("Ethnic Group")) {\r
- /*getEntity().removeModifier(modifier);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_EthnicGroup.getSelection());\r
- } \r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Ethnic Group", "Ethnic Group", null);\r
- Marker markerPlantPart = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(markerPlantPart);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_EthnicGroup.getSelection());\r
- }\r
- \r
- \r
- }\r
- \r
+ Iterator<DefinedTerm> itrExistingModifiers = getEntity().getModifiers().iterator();\r
+ while (itrExistingModifiers.hasNext()) {\r
+ DefinedTerm modifier = itrExistingModifiers.next();\r
+ if(GetVocabularyType(modifier, combo_HumanGroup.getSelection().getTitleCache())) {\r
+ itrExistingModifiers.remove();\r
}\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Ethnic Group", "Ethnic Group", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_EthnicGroup.getSelection());\r
+ }\r
+ DefinedTerm ethnicGroup = combo_EthnicGroup.getSelection();\r
+ getEntity().addModifier(ethnicGroup);\r
+ } else {\r
+ Set<DefinedTerm> modifiers = getEntity().getModifiers();\r
+ if(!modifiers.isEmpty()) {\r
+\r
+ Iterator<DefinedTerm> itr = modifiers.iterator();\r
+ while (itr.hasNext()) {\r
+ DefinedTerm currentMod = itr.next();\r
+ if(GetVocabularyType(currentMod, UsageTermCollection.ethnicGroupLabel)) {\r
+ itr.remove();\r
}\r
- \r
- } \r
- }\r
- else {\r
- /*MarkerType markerType = MarkerType.NewInstance("Ethnic Group", "Ethnic Group", null);\r
- Marker marker = Marker.NewInstance(markerType, false);\r
- Modifier plantPart = combo_PlantPart.getSelection();\r
- plantPart.addMarker(marker);\r
- getEntity().addModifier(plantPart);*/\r
- getEntity().addModifier(combo_EthnicGroup.getSelection());\r
+ }\r
}\r
}\r
}\r
}\r
- \r
- \r
\r
- /** {@inheritDoc} */\r
+ /**\r
+ * This function Checks the vocabulary type\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(UsageTermCollection.ethnicGroupLabel)) && ((term.getPartOf() != null))) {\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
@Override\r
public void setEntity(CategoricalData entity) {\r
- // section_stateData.setEntity(entity);\r
super.setEntity(entity);\r
}\r
\r
@Override\r
public void widgetSelected(SelectionEvent e) {\r
Object eventSource = e.getSource();\r
- //This is causing an error on purpose fix the if statement below\r
- \r
- //e.getselection();\r
- //if(eventSource == combo_UseCategory.getControls()) {\r
for (Object object: combo_UseCategory.getControls()) {\r
if (object == eventSource) {\r
State selectedUseCategory = combo_UseCategory.getSelection();\r
if (selectedUseCategory != null) {\r
combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));\r
+\r
+ if (!getEntity().getStateData().isEmpty()) {\r
+ Iterator<StateData> itrExistingState = getEntity().getStateData().iterator();\r
+ while(itrExistingState.hasNext()) {\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(UsageTermCollection.useSubCategoryVocabularyLabel)) {\r
+ combo_UseSubCategory.setSelection(stateSelection(UsageTermCollection.useSubCategoryVocabularyLabel));\r
+ }\r
+ }\r
+ }\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<DefinedTerm> iterModifiers = getEntity().getModifiers().iterator();\r
+ while (iterModifiers.hasNext()) {\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
- State selectedUseCategory = combo_UseCategory.getSelection();\r
- if (selectedUseCategory != null) {\r
- combo_UseSubCategory.setTerms(setUseCategoryComboTerms(TermStore.getTerms(State.class, null, false),selectedUseCategory));\r
-\r
- }\r
- //}\r
- if (eventSource == combo_HumanGroup) {\r
- Modifier selectedHumanGroup = combo_HumanGroup.getSelection();\r
- if (selectedHumanGroup != null) {\r
- combo_EthnicGroup.setTerms(setEthnicGroupComboTerms(TermStore.getTerms(Modifier.class, null, false), selectedHumanGroup));\r
- }\r
- }\r
- */\r
-\r
}\r
\r
@Override\r
public void widgetDefaultSelected(SelectionEvent e) {\r
// TODO Auto-generated method stub\r
+ }\r
+
\r
+ @Override\r
+ public void fillFields() {\r
+ // TODO \r
+ //combo_UseCategory;\r
+ //combo_UseSubCategory;\r
+ //combo_PlantPart;\r
+ //combo_Country;\r
+ //combo_HumanGroup;\r
+ //combo_EthnicGroup;\r
}\r
\r
-}\r
+}