import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.services.EMenuService;
import org.eclipse.jface.layout.GridDataFactory;
import ca.odell.glazedlists.TreeList;
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
+import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator;
+import eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
+import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.MeasurementUnit;
-import eu.etaxonomy.cdm.model.term.TermNode;
-import eu.etaxonomy.cdm.model.term.TermTree;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
+import eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto;
+import eu.etaxonomy.cdm.persistence.dto.FeatureDto;
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermNodeDto;
+import eu.etaxonomy.cdm.persistence.dto.TermTreeDto;
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
import eu.etaxonomy.taxeditor.store.CdmStore;
private NatTable natTable;
- private Collection<RowWrapperDTO<?>> rowsToSave = new HashSet<>();
+// private Collection<RowWrapperDTO<?>> rowsToSave = new HashSet<>();
+ private HashMap<UUID, RowWrapperDTO<?>> rowsToMerge = new HashMap<>();
- private Map<Integer, Feature> indexToFeatureMap = new HashMap<>();
+ private Map<Integer, FeatureDto> indexToFeatureMap = new HashMap<>();
- private Map<Feature, List<TermDto>> categoricalFeatureToStateMap = new HashMap<>();
+ private Map<UUID, List<TermDto>> categoricalFeatureToStateMap = new HashMap<>();
private LinkedMap<String, String> propertyToLabelMap = new LinkedMap<>();
private Collection<SpecimenNodeWrapper> specimenCache = null;
- private Map<Feature, CategoricalDataHistogram> featureToHistogramMap = new HashMap<>();
-
- private Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap = new HashMap<>();
+ private Map<FeatureDto, CategoricalDataHistogram> featureToHistogramMap = new HashMap<>();
private ListDataProvider<Object> bodyDataProvider;
private FreezeLayer freezeLayer;
- private List<Feature> features;
+ private List<FeatureDto> features;
private CharacterMatrixPart part;
private CharacterMatrixToolbar toolbar;
private DescriptionTreeFormat treeFormat;
+// private List<UUID> descriptionUuidsToDelete;
+ Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> descriptionUuidsToDelete;
+
+ private List<SpecimenRowWrapperDTO> specimenToAdd;
+
+ private MouseEventMatcher mouseEventMatcher = null;
+
+ private Set<DescriptionBase> descriptionsToSave = new HashSet<>();
public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
super(parent, SWT.NONE);
natTable = new NatTable(this, false);
- createBottomToolbar();
+// createBottomToolbar();
}
btnToggleTree.setEnabled(!isTree);
btnCollapseAll.setEnabled(isTree);
btnExpandAll.setEnabled(isTree);
+
}
public boolean isTreeView() {
/**
* configuration
*/
+
configureNatTable(treeView, configRegistry, topMostLayer);
/**
//grab all space
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
- //update label to current data set
- toolbar.getWsLabel().setText(getDescriptiveDataSet().getLabel());
+ //update label to current dataset
+ toolbar.getWsLabel().setText(getDescriptiveDataSet().getTitleCache());
toolbar.getWsLabel().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
toolbar.getWsLabel().getParent().layout();
getNatTableState().remove(PersistenceDialog.ACTIVE_VIEW_CONFIGURATION_KEY);
}
- private List<Feature> initFeatureList(TermNode<Feature> node){
- List<Feature> features = new ArrayList<>();
- List<TermNode<Feature>> childNodes = node.getChildNodes();
- for (TermNode<Feature> childNode : childNodes) {
- features.add(childNode.getTerm());
- features.addAll(initFeatureList(childNode));
+ private List<FeatureDto> initFeatureList(TermNodeDto node){
+ List<FeatureDto> features = new ArrayList<>();
+ List<TermNodeDto> childNodes = node.getChildren();
+ for (TermNodeDto childNode : childNodes) {
+ if (childNode != null){
+ features.add((FeatureDto) childNode.getTerm());
+ features.addAll(initFeatureList(childNode));
+ }
}
return features;
}
public void initDescriptiveDataSet(){
- //get features/columns stored in descriptive data set
- TermTree<Feature> tree = getDescriptiveDataSet().getDescriptiveSystem();
+ //get features/columns stored in descriptive dataset
+ TermTreeDto tree = getDescriptiveDataSet().getDescriptiveSystem();
features = initFeatureList(tree.getRoot());
- Set<Feature> duplicateFeatures = features.stream().filter(i -> Collections.frequency(features, i) >1)
+ Set<FeatureDto> duplicateFeatures = features.stream().filter(i -> Collections.frequency(features, i) >1)
.collect(Collectors.toSet());
if (!duplicateFeatures.isEmpty()) {
throw new IllegalArgumentException("Duplicate features found: "
- + duplicateFeatures.stream().map(feature -> feature.getLabel()).collect(Collectors.joining(",")));
+ + duplicateFeatures.stream().map(feature -> feature.getRepresentation_L10n()).collect(Collectors.joining(",")));
}
//init state data for categorical features
- features.forEach(feature->fetchSupportedStates(feature));
+// features.forEach(feature->fetchSupportedStates(feature));
+ fetchSupportedStates(features);
descriptions = new BasicEventList<>();
}
- private void fetchSupportedStates(Feature feature) {
- List<TermDto> supportedStates = CdmStore.getService(IDescriptiveDataSetService.class).getSupportedStatesForFeature(feature.getUuid());
- categoricalFeatureToStateMap.put(feature, supportedStates);
+ private void fetchSupportedStates(List<FeatureDto> features) {
+ Set<UUID> featureUuids = new HashSet<>();
+ features.forEach(i->featureUuids.add(i.getUuid()));
+ categoricalFeatureToStateMap = CdmStore.getService(IDescriptiveDataSetService.class).getSupportedStatesForFeature(featureUuids);
+
}
+
+
private void createLayers(boolean treeView) {
+
SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
// wrap the SortedList with the TreeList
treeFormat = new DescriptionTreeFormat(getDescriptiveDataSet());
TreeList<Object> treeList = new TreeList(sortedList, treeFormat, TreeList.NODES_START_COLLAPSED);
+ // wrap the SortedList with the TreeList
+// treeFormat = new DescriptionTreeFormat(getDescriptiveDataSet());
+
/**
* data provider
*/
SpecimenColumnPropertyAccessor columnPropertyAccessor = new SpecimenColumnPropertyAccessor(this);
bodyDataProvider = treeView?new ListDataProvider<>(treeList, columnPropertyAccessor):new ListDataProvider<>(sortedList, columnPropertyAccessor);
- configRegistry = new ConfigRegistry();
+ DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
+ bodyDataLayer.registerCommandHandler(new CopyPasteUpdateDataCommandHandler(bodyDataLayer));
/**
*
*/
- DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
- bodyDataLayer.registerCommandHandler(new CopyPasteUpdateDataCommandHandler(bodyDataLayer));
+ configRegistry = new ConfigRegistry();
//register labels
CharacterMatrixConfigLabelAccumulator labelAccumulator = new CharacterMatrixConfigLabelAccumulator(this);
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
propertyToLabelMap.put(IDENTIFIER_COLUMN, Messages.CharacterMatrix_IDENTIFIER);
propertyToLabelMap.put(COUNTRY_COLUMN, Messages.CharacterMatrix_COUNTRY);
for(int i=0;i<features.size();i++){
- Feature feature = features.get(i);
+ FeatureDto feature = features.get(i);
initLabels(i, feature);
}
// assemble the column groups
LinkedList<ColumnGroupWrapper> columnGroups = new LinkedList<>();
- List<TermNode<Feature>> rootChildren = getDescriptiveDataSet().getDescriptiveSystem().getRootChildren();
+ List<TermNodeDto> rootChildren = getDescriptiveDataSet().getDescriptiveSystem().getRoot().getChildren();
buildHeader(rootChildren, columnGroups);
bodyLayer = new MatrixBodyLayerStack(eventLayer, columnGroups);
freezeLayer = new FreezeLayer(selectionLayer);
final CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(
freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
- TreeLayer treeLayer = new TreeLayer(compositeFreezeLayer, treeRowModel);
+ TreeLayer treeLayer = null;
+ if (treeView){
+ treeLayer = new TreeLayer(compositeFreezeLayer, treeRowModel);
+ }
topMostLayer = treeView?treeLayer:compositeFreezeLayer;
ColumnGroupHeaderLayer groupLayerLevel1 = null;
ColumnGroupGroupHeaderLayer groupLayerLevel2 = null;
groupLayerLevel1 = new ColumnGroupHeaderLayer(columnHeaderLayer, selectionLayer, groupLevel1.getModel());
- for (Entry<TermNode<Feature>, TreeSet<Integer>> entry: groupLevel1.getColumnGroupToIndexMap().entrySet()) {
- TermNode<Feature> group = entry.getKey();
+ for (Entry<TermNodeDto, TreeSet<Integer>> entry: groupLevel1.getColumnGroupToIndexMap().entrySet()) {
+ TermNodeDto group = entry.getKey();
TreeSet<Integer> indexList = entry.getValue();
int[] intArray = indexList.stream().mapToInt(Integer::intValue).toArray();
groupLayerLevel1.addColumnsIndexesToGroup(group.getTerm().getTitleCache(), intArray);
if(columnGroups.size()>1){
ColumnGroupWrapper groupLevel2 = columnGroups.get(1);
groupLayerLevel2 = new ColumnGroupGroupHeaderLayer(groupLayerLevel1, selectionLayer, groupLevel2.getModel());
- for (Entry<TermNode<Feature>, TreeSet<Integer>> entry: groupLevel2.getColumnGroupToIndexMap().entrySet()) {
- TermNode<Feature> group = entry.getKey();
+ for (Entry<TermNodeDto, TreeSet<Integer>> entry: groupLevel2.getColumnGroupToIndexMap().entrySet()) {
+ TermNodeDto group = entry.getKey();
TreeSet<Integer> indexList = entry.getValue();
int[] intArray = indexList.stream().mapToInt(Integer::intValue).toArray();
groupLayerLevel2.addColumnsIndexesToGroup(group.getTerm().getTitleCache(), intArray);
}
- private TreeSet<Integer> recurseChildIndexes(TermNode<Feature> node){
+ private TreeSet<Integer> recurseChildIndexes(TermNodeDto node){
TreeSet<Integer> childIndexes = new TreeSet<>();
- if(node.getChildCount()>0){
- List<TermNode<Feature>> childNodes = node.getChildNodes();
- for (TermNode<Feature> childNode: childNodes) {
- childIndexes.addAll(recurseChildIndexes(childNode));
+ if(node.getChildren().size() >0){
+ List<TermNodeDto> childNodes = node.getChildren();
+ for (TermNodeDto childNode: childNodes) {
+ if (childNode != null){
+ childIndexes.addAll(recurseChildIndexes(childNode));
+ }
}
}
childIndexes.add(features.indexOf(node.getTerm())+LEADING_COLUMN_COUNT);
return childIndexes;
}
- private void buildHeader(List<TermNode<Feature>> nodes, LinkedList<ColumnGroupWrapper> columnGroups){
- Map<TermNode<Feature>, TreeSet<Integer>> columnGroupToIndexMap = new HashMap<>();
- List<TermNode<Feature>> childNodes = new ArrayList<>();
- for (TermNode<Feature> node : nodes) {
- TreeSet<Integer> childIndexes = recurseChildIndexes(node);
- if(childIndexes.size()>1){
- // filter out groups that only have one member
- columnGroupToIndexMap.put(node, childIndexes);
+ private void buildHeader(List<TermNodeDto> nodes, LinkedList<ColumnGroupWrapper> columnGroups){
+ Map<TermNodeDto, TreeSet<Integer>> columnGroupToIndexMap = new HashMap<>();
+ List<TermNodeDto> childNodes = new ArrayList<>();
+ for (TermNodeDto node : nodes) {
+ if (node != null){
+ TreeSet<Integer> childIndexes = recurseChildIndexes(node);
+ if(childIndexes.size()>1){
+ // filter out groups that only have one member
+ columnGroupToIndexMap.put(node, childIndexes);
+ }
+ childNodes.addAll(node.getChildren());
}
- childNodes.addAll(node.getChildNodes());
}
if(!columnGroupToIndexMap.isEmpty()){
columnGroups.addFirst(new ColumnGroupWrapper(new ColumnGroupModel(), columnGroupToIndexMap));
/**
* CONFIGURATION
*/
+ //+++CONTEXT MENU+++
+ menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
+ // get the menu registered by EMenuService
+ final Menu e4Menu = natTable.getMenu();
+
natTable.setConfigRegistry(configRegistry);
applyStyles();
// add the header menu configuration for adding the column header menu
// with hide/show actions
- natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
+// natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
// add custom configuration for data conversion and add column labels to viewport layer
topMostLayer.addConfiguration(new CellEditorDataConversionConfiguration(this));
//copy&paste configuration
natTable.addConfiguration(new CopyPasteEditBindings(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
- //+++CONTEXT MENU+++
- menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
- // get the menu registered by EMenuService
- final Menu e4Menu = natTable.getMenu();
+
// remove the menu reference from NatTable instance
natTable.setMenu(null);
+
+
+// natTable.addConfiguration(new CharacterMatrixHeaderMenuConfiguration(natTable));
+
+
+ natTable.configure();
+
+
natTable.addConfiguration(
- new AbstractUiBindingConfiguration() {
- @Override
- public void configureUiBindings(
- UiBindingRegistry uiBindingRegistry) {
- // add e4 menu to NatTable
- new PopupMenuBuilder(natTable, e4Menu)
+ new AbstractUiBindingConfiguration() {
+ @Override
+ public void configureUiBindings(
+ UiBindingRegistry uiBindingRegistry) {
+ // add e4 menu to NatTable
+
+
+ uiBindingRegistry.unregisterMouseDownBinding(mouseEventMatcher);
+ new PopupMenuBuilder(natTable, e4Menu)
+ .withHideColumnMenuItem()
+ .withShowAllColumnsMenuItem()
.build();
- // register the UI binding for header, corner and body region
- uiBindingRegistry.registerMouseDownBinding(
- new MouseEventMatcher(
- SWT.NONE,
- null,
- MouseEventMatcher.RIGHT_BUTTON),
- new PopupMenuAction(e4Menu));
- }
- });
+ // register the UI binding for header, corner and body region
+ mouseEventMatcher = new MouseEventMatcher(
+ SWT.NONE,
+ null,
+ MouseEventMatcher.RIGHT_BUTTON);
+ uiBindingRegistry.registerMouseDownBinding(mouseEventMatcher,
+ new PopupMenuAction(e4Menu));
+ }
+ });
- natTable.configure();
}
void freezeSupplementalColumns(boolean freeze){
}
}
- private void initLabels(int index, Feature feature) {
+ private void initLabels(int index, FeatureDto feature) {
indexToFeatureMap.put(index+LEADING_COLUMN_COUNT, feature);
- String label = feature.getLabel();
+ String label = feature.getTitleCache();
String property = feature.getUuid().toString();
//show unit for quantitative data
if(feature.isSupportsQuantitativeData()){
- Set<MeasurementUnit> recommendedMeasurementUnits = feature.getRecommendedMeasurementUnits();
+ Set<TermDto> recommendedMeasurementUnits = feature.getRecommendedMeasurementUnits();
// if(recommendedMeasurementUnits.size()>1){
// MessagingUtils.warningDialog(Messages.CharacterMatrix_INIT_PROBLEM, CharacterMatrix.class,
// String.format(Messages.CharacterMatrix_INIT_PROBLEM_MESSAGE, feature.getLabel()));
// }
if(recommendedMeasurementUnits.size()==1){
- MeasurementUnit unit = recommendedMeasurementUnits.iterator().next();
+ TermDto unit = recommendedMeasurementUnits.iterator().next();
label += " ["+unit.getIdInVocabulary()+"]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
propertyToLabelMap.put(property, label);
}
- public void loadDescriptions(UUID descriptiveDataSetUuid, boolean isInitialExpandToDeepestTaxonLevel) {
- UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().monitGetRowWrapper(descriptiveDataSetUuid);
+ public void loadDescriptions(boolean isInitialExpandToDeepestTaxonLevel, boolean initialLoading) {
+ UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().monitGetRowWrapper(this.getDescriptiveDataSet().getUuid());
final Collection<RowWrapperDTO> wrappers = new ArrayList<>();
String jobLabel = Messages.CharacterMatrix_LOAD_CHARACTER_DATA;
}
descriptions.clear();
wrappers.stream().filter(row->row.getTaxonNode()!=null).forEach(wrapper->CharacterMatrix.this.descriptions.add(wrapper));
- loadingDone(isInitialExpandToDeepestTaxonLevel);
+ if(initialLoading){
+ loadingDone(isInitialExpandToDeepestTaxonLevel);
+ }
+
});
}
});
private void loadingDone(boolean isInitialExpandToDeepestTaxonLevel) {
this.part.loadingDone();
createTable(isTreeView, freezeLayer.isFrozen(), isInitialExpandToDeepestTaxonLevel);
+
+ }
+
+ public List<TermDto> getSupportedStatesForCategoricalFeature(UUID featureUuid){
+ return categoricalFeatureToStateMap.get(featureUuid);
}
- public List<TermDto> getSupportedStatesForCategoricalFeature(Feature feature){
- return categoricalFeatureToStateMap.get(feature);
+ public Set<DescriptionBase> getDescriptionsToSave() {
+ return descriptionsToSave;
}
- public Map<Integer, Feature> getIndexToFeatureMap() {
+ public void addDescriptionToSave(DescriptionBase descriptionToSave) {
+ this.descriptionsToSave.add(descriptionToSave);
+ }
+
+ public Map<Integer, FeatureDto> getIndexToFeatureMap() {
return indexToFeatureMap;
}
part.setDirty();
}
+ public Map<RemoveDescriptionsFromDescriptiveDataSetConfigurator, List<UUID>> getDescriptionsToDelete() {
+ return descriptionUuidsToDelete;
+ }
+
+ public void addDescriptionToDelete(UUID descriptionToDelete, RemoveDescriptionsFromDescriptiveDataSetConfigurator config) {
+ if (descriptionUuidsToDelete == null){
+ descriptionUuidsToDelete = new HashMap<>();
+ }
+ if (descriptionUuidsToDelete.get(config) != null){
+ descriptionUuidsToDelete.get(config).add(descriptionToDelete);
+ }else{
+ List<UUID> uuidList = new ArrayList<>();
+ uuidList.add(descriptionToDelete);
+ this.descriptionUuidsToDelete.put(config, uuidList);
+ }
+
+
+ }
+
+ public List<SpecimenRowWrapperDTO> getSpecimenToAdd() {
+ return specimenToAdd;
+ }
+
+ public void addSpecimenToAdd(Collection<SpecimenRowWrapperDTO> specimenToAdd) {
+ if (this.specimenToAdd == null){
+ this.specimenToAdd = new ArrayList();
+ }
+
+ this.specimenToAdd.addAll(specimenToAdd);
+ this.specimenCache.removeAll(specimenToAdd);
+ }
+ public void addSpecimenToAdd(SpecimenRowWrapperDTO specimenToAdd) {
+ if (this.specimenToAdd == null){
+ this.specimenToAdd = new ArrayList();
+ }
+
+ this.specimenToAdd.add(specimenToAdd);
+ this.specimenCache.remove(specimenToAdd);
+ }
+
public CharacterMatrixPart getPart() {
return part;
}
return descriptions;
}
- public DescriptiveDataSet getDescriptiveDataSet() {
+ public DescriptiveDataSetBaseDto getDescriptiveDataSet() {
return part.getDescriptiveDataSet();
}
- public void setDescriptiveDataSet(DescriptiveDataSet dataSet) {
+ public void setDescriptiveDataSet(DescriptiveDataSetBaseDto dataSet) {
part.setDescriptiveDataSet(dataSet);
}
public Collection<SpecimenNodeWrapper> getSpecimenCache() {
- return specimenCache;
+ return specimenCache;
}
public void setSpecimenCache(Collection<SpecimenNodeWrapper> specimenCache) {
//map descriptions on a list of uuids of the described specimen
!this.descriptions.stream()
.filter(rowWrapper->rowWrapper instanceof SpecimenRowWrapperDTO)
- .map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimen().getUuid())
+ .map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimenDto().getUuid())
.collect(Collectors.toList())
//and check if the specimen to add is already contained
.contains(wrapper.getUuidAndTitleCache().getUuid())
.collect(Collectors.toList());
}
- public void addRowToSave(RowWrapperDTO<?> row){
- rowsToSave.add(row);
+// public void addRowToSave(RowWrapperDTO<?> row){
+// rowsToMerge.put(row.getDescription().getDescription().getUuid(), row);
+// }
+//
+// public HashMap<UUID,RowWrapperDTO<?>> getRowsToSave() {
+// return rowsToMerge;
+// }
+
+ public HashMap<UUID, RowWrapperDTO<?>> getRowsToMerge() {
+ return rowsToMerge;
}
- public Collection<RowWrapperDTO<?>> getRowsToSave() {
- return rowsToSave;
+ public void putRowToMerge(RowWrapperDTO rowToMerge) {
+ if (this.rowsToMerge == null){
+ this.rowsToMerge = new HashMap<>();
+ }
+ this.rowsToMerge.put(rowToMerge.getDescription().getDescriptionUuid(), rowToMerge);
}
public Properties getNatTableState() {
return new File(WorkbenchUtility.getBaseLocation(), CHARACTER_MATRIX_STATE_PROPERTIES);
}
- public List<Feature> getFeatures() {
+ public List<FeatureDto> getFeatures() {
return features;
}
- public Map<Feature, CategoricalDataHistogram> getFeatureToHistogramMap() {
+ public Map<FeatureDto, CategoricalDataHistogram> getFeatureToHistogramMap() {
return featureToHistogramMap;
}
- public Map<Feature, QuantitativeDataStatistics> getFeatureToQuantDataStatisticsMap() {
- return featureToQuantDataStatisticsMap;
- }
+
public ICdmEntitySession getCdmEntitiySession(){
return part.getCdmEntitySession();
}
+ @Inject
+ @Optional
+ private void updateSpecimenList(@UIEventTopic(WorkbenchEventConstants.REFRESH_DESCRIPTIVE_DATASET)UUID uuid){
+ if(uuid!= null && uuid.equals(part.getDescriptiveDataSet().getUuid())){
+ this.specimenCache = null;
+
+ }
+ }
+
+ public void addRowsToMatrix(Collection<SpecimenNodeWrapper> wrappers){
+
+ List<UUID> specimenUuids = new ArrayList();
+ wrappers.forEach(wrapper -> specimenUuids.add(wrapper.getUuidAndTitleCache().getUuid()));
+// List<SpecimenOrObservationBase> specimens = CdmStore.getService(IOccurrenceService.class).load(specimenUuids, null);
+ Map<UUID, UuidAndTitleCache<FieldUnit>> specimenMap = new HashMap();
+
+ for (UUID specimenUuid: specimenUuids ){
+ try{
+ FieldUnitDTO fieldUnitDto = CdmStore.getService(IOccurrenceService.class).loadFieldUnitDTO(specimenUuid);
+ if (fieldUnitDto != null){
+ UuidAndTitleCache<FieldUnit> fieldUnit = new UuidAndTitleCache(FieldUnit.class, fieldUnitDto.getUuid(), null, fieldUnitDto.getLabel());
+ specimenMap.put(specimenUuid, fieldUnit);
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ }
+ for (SpecimenNodeWrapper wrapper: wrappers){
+ SpecimenRowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createSpecimenRowWrapper(wrapper.getUuidAndTitleCache().getUuid(), wrapper.getTaxonNode().getUuid(), getDescriptiveDataSet().getUuid());
+ addSpecimenToAdd(rowWrapper);
+// SpecimenRowWrapperDTO rowWrapper = new SpecimenRowWrapperDTO(wrapper.getUuidAndTitleCache(), wrapper.getType(), wrapper.getTaxonNode(), specimenMap.get(wrapper.getUuidAndTitleCache().getUuid()), null, null);
+ descriptions.add(rowWrapper);
+ }
+
+
+ setDirty();
+ }
+
+ public HashMap<UUID, DescriptionBase> addSpecimensToDescriptiveDataSet(){
+ if (specimenToAdd == null || specimenToAdd.isEmpty()){
+ return new HashMap<>();
+ }
+ UpdateResult result = CdmStore.getService(IDescriptiveDataSetService.class).addRowWrapperToDataset(specimenToAdd, getDescriptiveDataSet().getUuid());
+ if(!result.getExceptions().isEmpty()){
+ MessagingUtils.warningDialog(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_TITLE, this,
+ String.format(Messages.CharacterMatrixBottomToolbar_ERROR_ROW_CREATION_MESSAGE, result.getExceptions()
+ .stream().map(ex->ex.toString())
+ .collect(Collectors.joining("\n"))));
+ }
+ DescriptiveDataSet dataSet = (DescriptiveDataSet) result.getCdmEntity();
+ HashMap<UUID, DescriptionBase> resultMap = new HashMap<>();
+ for (CdmBase updated: result.getUpdatedObjects()){
+ if (updated instanceof SpecimenDescription){
+ resultMap.put(updated.getUuid(), (DescriptionBase)updated);
+ }
+
+
+ }
+ dataSet = this.getCdmEntitiySession().load(dataSet, true);
+ // update local dataset
+ DescriptiveDataSetBaseDto dto = DescriptiveDataSetBaseDto.fromDescriptiveDataSet(dataSet);
+ this.setDescriptiveDataSet(dto);
+
+ //these descriptions are already updated
+ for (SpecimenRowWrapperDTO row: specimenToAdd){
+ this.rowsToMerge.remove(row.getDescription().getDescriptionUuid());
+ }
+ specimenToAdd.clear();
+ return resultMap;
+
+ }
+
+ @Inject
+ @Optional
+ private void updateView(@UIEventTopic(WorkbenchEventConstants.ADD_TO_MERGE_ROWS) UUID uuid) {
+
+ }
+
+ @Override
+ public void dispose () {
+ super.dispose();
+ descriptions.dispose();
+ descriptions = null;
+ this.natTable.dispose();
+ this.natTable = null;
+ categoricalFeatureToStateMap = null;
+ rowsToMerge.clear();
+ rowsToMerge = null;
+ indexToFeatureMap = null;
+ propertyToLabelMap = null;
+ specimenCache = null;
+ featureToHistogramMap = null;
+ bodyDataProvider = null;
+ freezeLayer = null;
+ features = null;
+ topMostLayer.dispose();
+ topMostLayer = null;
+ configRegistry = null;
+ bodyLayer.dispose();
+ bodyLayer = null;
+ toolbar.dispose();
+ toolbar = null;
+ treeFormat = null;
+ descriptionUuidsToDelete = null;
+ specimenToAdd = null;
+ mouseEventMatcher = null;
+ descriptionsToSave = null;
+ menuService = null;
+ sync = null;
+ part = null;
+
+ }
+
}