import java.util.UUID;
-import eu.etaxonomy.cdm.vaadin.view.registration.ExistingNameRegistrationType;
-
/**
* @author a.kohlbecker
* @since Mar 3, 2017
private Action action;
private UUID citationUuid = null;
- private ExistingNameRegistrationType type;
/**
*
* @param citationID the id of a {@link Reference} denoting a
* complete registration working set.
*/
- public RegistrationWorkingsetAction(UUID citationUuid, Action action, ExistingNameRegistrationType type){
+ public RegistrationWorkingsetAction(UUID citationUuid, Action action){
this.action = action;
this.citationUuid = citationUuid;
- this.type = type;
}
/**
return action.equals(Action.start);
}
- public ExistingNameRegistrationType getType() {
- return type;
- }
-
public enum Action {
start, open;
+++ /dev/null
-/**
-* Copyright (C) 2018 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.vaadin.view.registration;
-
-public enum ExistingNameRegistrationType {
- NAME_TYPIFICATION("covering the name and typifications"),
- TYPIFICATION_ONLY("covering typifications only");
-
- private String caption;
-
- ExistingNameRegistrationType(String caption){
- this.caption = caption;
- }
-
- @Override
- public String toString() {
- return caption;
- }
-
-
-}
\ No newline at end of file
/**
* Checks
* <ol>
- * <li>if there is any registration for this name created in the current registration system</li>
+ * <li>if there is NOT any registration for this name created in the current registration system</li>
* <li>Checks if the name belongs to the current workingset</li>
* </ol>
* If both checks are successful the method returns <code>true</code>.
*/
- public boolean canCreateRegistrationForName(TaxonName name) {
- for(Registration reg : name.getRegistrations()){
- if(minter.isFromOwnRegistration(reg.getIdentifier())){
- return false;
- }
- }
+ public boolean canCreateNameRegistrationFor(TaxonName name) {
+ return !checkRegistrationExistsFor(name) && checkWokingsetContainsProtologe(name);
+ }
+
+ /**
+ * @param name
+ * @return
+ */
+ public boolean checkWokingsetContainsProtologe(TaxonName name) {
Reference nomRef = name.getNomenclaturalReference();
UUID citationUuid = workingset.getCitationUuid();
// @formatter:off
// @formatter:on
}
+ /**
+ * @param name
+ */
+ public boolean checkRegistrationExistsFor(TaxonName name) {
+
+ for(Registration reg : name.getRegistrations()){
+ if(minter.isFromOwnRegistration(reg.getIdentifier())){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
/**
* @param taxonNameId
// here we completely ignore the ExistingNameRegistrationType since the user should not have the choice
// to create a typification only registration in the working (publication) set which contains
// the protologe. This is known from the nomenclatural reference.
- if(canCreateRegistrationForName(typifiedName)){
- // the citation which is the base for workingset contains the protologe of the name and the name hast not
+ if(canCreateNameRegistrationFor(typifiedName)){
+ // the citation which is the base for workingset contains the protologe of the name and the name has not
// been registered before:
// create a registration for the name and the first typifications
Registration newRegistrationWithExistingName = createNewRegistrationForName(typifiedName.getUuid());
newRegistrationDTOWithExistingName = new RegistrationDTO(newRegistrationWithExistingName, typifiedName, citation);
reloadWorkingSet = true;
} else {
- // create a typification only registration
- // FIXME: this should not be possible if the names protologue is in the workingset --> #
- Registration newRegistrationWithExistingName = createNewRegistrationForName(null);
- newRegistrationDTOWithExistingName = new RegistrationDTO(newRegistrationWithExistingName, typifiedName, citation);
+ if(!checkWokingsetContainsProtologe(typifiedName)){
+ // create a typification only registration
+ Registration typificationOnlyRegistration = createNewRegistrationForName(null);
+ if(!checkRegistrationExistsFor(typifiedName)){
+ // oops, yet no registration for this name, so we create it as blocking registration:
+ Registration blockingNameRegistration = createNewRegistrationForName(typifiedName.getUuid());
+ typificationOnlyRegistration.getBlockedBy().add(blockingNameRegistration);
+ }
+ newRegistrationDTOWithExistingName = new RegistrationDTO(typificationOnlyRegistration, typifiedName, citation);
+ }
}
workingset.add(newRegistrationDTOWithExistingName);
// tell the view to update the workingset
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
-import com.vaadin.ui.ListSelect;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.UI;
public class RegistrationWorksetViewBean extends AbstractPageView<RegistrationWorkingsetPresenter>
implements RegistrationWorkingsetView, View, AccessRestrictedView {
- /**
- *
- */
+
private static final int COL_INDEX_STATE_LABEL = 0;
- /**
- *
- */
private static final int COL_INDEX_REG_ITEM = 1;
- /**
- *
- */
private static final int COL_INDEX_BUTTON_GROUP = 2;
public static final String DOM_ID_WORKINGSET = "workingset";
+ public static final String TEXT_NAME_TYPIFICATION = "covering the name and typifications";
+ public static final String TEXT_TYPIFICATION_ONLY = "covering typifications only";
+
private static final long serialVersionUID = -213040114015958970L;
public static final String NAME = "workingset";
private Button addExistingNameButton;
- private ListSelect existingNameRegistrationTypeSelect;
+ private Label existingNameRegistrationTypeLabel;
private RegistrationItem workingsetHeader;
addNewNameRegistrationButton.addClickListener(
e -> getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, null, this)));
- existingNameRegistrationTypeSelect = new ListSelect(null, EnumSet.allOf(ExistingNameRegistrationType.class));
- existingNameRegistrationTypeSelect.setRows(1);
- existingNameRegistrationTypeSelect.setNullSelectionAllowed(true);
- existingNameRegistrationTypeSelect.setEnabled(false);
+ existingNameRegistrationTypeLabel = new Label();
addExistingNameButton = new Button("existing name:");
addExistingNameButton.setEnabled(false);
addExistingNameButton.addClickListener(
e -> getViewEventBus().publish(this, new RegistrationWorkingsetAction(
citationUuid,
- RegistrationWorkingsetAction.Action.start,
- (ExistingNameRegistrationType)existingNameRegistrationTypeSelect.getValue())
+ RegistrationWorkingsetAction.Action.start
)
- );
+ )
+ );
existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class);
existingNameCombobox.addValueChangeListener(
e -> {
boolean selectionNotEmpty = e.getProperty().getValue() != null;
- addExistingNameButton.setEnabled(selectionNotEmpty);
- existingNameRegistrationTypeSelect.setEnabled(selectionNotEmpty);
+ addExistingNameButton.setEnabled(false);
+ existingNameRegistrationTypeLabel.setValue(null);
if(selectionNotEmpty){
TaxonName name = (TaxonName)e.getProperty().getValue();
- if(getPresenter().canCreateRegistrationForName(name)){
- existingNameRegistrationTypeSelect.setValue(ExistingNameRegistrationType.NAME_TYPIFICATION);
- existingNameRegistrationTypeSelect.setEnabled(true);
- existingNameRegistrationTypeSelect.setNullSelectionAllowed(false);
+ if(getPresenter().canCreateNameRegistrationFor(name)){
+ existingNameRegistrationTypeLabel.setValue(TEXT_NAME_TYPIFICATION);
+ addExistingNameButton.setEnabled(true);
} else {
- existingNameRegistrationTypeSelect.setValue(ExistingNameRegistrationType.TYPIFICATION_ONLY);
- existingNameRegistrationTypeSelect.setEnabled(false);
+ if(!getPresenter().checkWokingsetContainsProtologe(name)){
+ existingNameRegistrationTypeLabel.setValue(TEXT_TYPIFICATION_ONLY);
+ addExistingNameButton.setEnabled(true);
+ }
}
} else {
- existingNameRegistrationTypeSelect.setNullSelectionAllowed(true);
- existingNameRegistrationTypeSelect.clear();
- existingNameRegistrationTypeSelect.setEnabled(false);
-
+ existingNameRegistrationTypeLabel.setValue(null);
}
}
);
addRegistrationLabel_2,
addExistingNameButton,
existingNameCombobox,
- existingNameRegistrationTypeSelect
+ existingNameRegistrationTypeLabel
);
buttonContainer.setSpacing(true);
// buttonContainer.setWidth(100, Unit.PERCENTAGE);