Project

General

Profile

Revision 7b9ab0e4

ID7b9ab0e4d2a0e8be83f0d21e43d2722877955786
Parent 0b673f50
Child 6f943bcd

Added by Andreas Kohlbecker almost 3 years ago

ref #7195 creating blocking relations and showing 'em in the listView

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
28 28
import com.vaadin.ui.CssLayout;
29 29
import com.vaadin.ui.GridLayout;
30 30
import com.vaadin.ui.Label;
31
import com.vaadin.ui.Layout;
31 32
import com.vaadin.ui.Link;
33
import com.vaadin.ui.Panel;
32 34
import com.vaadin.ui.themes.ValoTheme;
33 35

  
34 36
import eu.etaxonomy.cdm.model.common.TimePeriod;
......
73 75

  
74 76
    private AbstractView<?> parentView;
75 77

  
78
    private RegistrationDTO regDto;
79

  
80
    private boolean showBlockingRelations = false;
81

  
76 82
    private TimePeriodFormatter timePeriodFormatter = new TimePeriodFormatter(DateTimeFormat.ISO8601_DATE);
77 83

  
78 84
    // --------------------------------------------------
......
88 94
    private Label publishedLabel = new Label();
89 95
    private Label releasedLabel = new Label();
90 96

  
97
    private Panel blockingRelationsPanel;
98

  
91 99
    /**
92 100
     *
93 101
     */
......
170 178
    }
171 179

  
172 180
    public void setItem(RegistrationDTO regDto, AbstractView<?> parentView){
181

  
173 182
        this.parentView = parentView;
174 183

  
184
        this.regDto = regDto;
185

  
175 186
        NavigationEvent navigationEvent = null;
176 187
        if(regDto.getCitationID() != null) {
177 188
            navigationEvent = new NavigationEvent(
......
182 193
            setComponentError(new UserError("Citation is missing"));
183 194
        }
184 195

  
196
        if(showBlockingRelations){
197
            createBlockingRelationsContent();
198
        }
199

  
185 200
        updateUI(regDto.getBibliographicCitationString(), regDto.getCreated(), regDto.getDatePublished(), regDto.getMessages().size(),
186 201
                navigationEvent, null, regDto, regDto.getSubmitterUserName());
187 202
    }
......
210 225
                referenceEditorAction, FontAwesome.EDIT, null, submitterName);
211 226
    }
212 227

  
228
    private void createBlockingRelationsContent(){
229

  
230
        if(blockingRelationsPanel == null && !regDto.getBlockedBy().isEmpty()){
231
            blockingRelationsPanel = new Panel("blocked by");
232
            Layout blockingRelations = new CssLayout();
233
            blockingRelations.setWidth(100, Unit.PERCENTAGE);
234
            blockingRelationsPanel.setContent(blockingRelations);
235
            for(RegistrationDTO blockRegDto : regDto.getBlockedBy()){
236
                RegistrationItem blockRegItem = new RegistrationItem(blockRegDto, parentView);
237
                blockingRelations.addComponent(blockRegItem);
238
            }
239
            blockingRelationsPanel.setWidth(100, Unit.PERCENTAGE);
240
            addComponent(blockingRelationsPanel, 0, 4, GRID_COLS - 1, 4);
241
        }
242

  
243
    }
244

  
213 245
    /**
214 246
     * @param submitterUserName TODO
215 247
     *
......
245 277
            getMessageButton().setCaptionAsHtml(true);
246 278
        }
247 279

  
248
        if(regDto != null && regDto.getBlockedBy() != null && regDto.getBlockedBy().size() > 0){
280
        if(regDto != null && !regDto.getBlockedBy().isEmpty()){
249 281
            getBlockedByButton().setEnabled(true);
250 282
            getBlockedByButton().addStyleName("blocked");
251 283
        }
......
381 413
        return submitterLabel;
382 414
    }
383 415

  
416
    /**
417
     * @return the showBlockingRelations
418
     */
419
    public boolean isShowBlockingRelations() {
420
        return showBlockingRelations;
421
    }
422

  
423
    /**
424
     * @param showBlockingRelations the showBlockingRelations to set
425
     */
426
    public void setShowBlockingRelations(boolean showBlockingRelations) {
427
        if(showBlockingRelations && !this.showBlockingRelations){
428
            createBlockingRelationsContent();
429
        }
430
        this.showBlockingRelations = showBlockingRelations;
431
    }
432

  
433

  
384 434

  
385 435
   /* --------------------------------------- */
386 436

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
157 157
            RegistrationItem item = new RegistrationItem(regDto, this);
158 158
            item.getSubmitterLabel().setVisible(isCurator);
159 159
            item.setWidth(100, Unit.PERCENTAGE);
160
            item.getBlockedByButton().addClickListener(e -> item.setShowBlockingRelations(true));
160 161
            listContainer.addComponent(item);
161 162
        }
162 163
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationDTO.java
58 58

  
59 59
    private List<String> messages = new ArrayList<>();
60 60

  
61
    // private Set<eu.etaxonomy.cdm.model.name.Registration> blockedBy = new HashSet<>();
61
    private Set<RegistrationDTO> blockedBy;
62 62

  
63 63

  
64 64
    /**
......
362 362
    /**
363 363
     * @return the blockedBy
364 364
     */
365
    public Set<Registration> getBlockedBy() {
366
        return reg.getBlockedBy();
365
    public Set<RegistrationDTO> getBlockedBy() {
366

  
367
        if(blockedBy == null){
368
            blockedBy = new HashSet<>();
369
            if(reg.getBlockedBy() != null){
370
                for(Registration blockReg : reg.getBlockedBy()){
371
                    blockedBy.add(new RegistrationDTO(blockReg));
372
                }
373
            }
374
        }
375
        return blockedBy;
367 376
    }
368 377

  
369 378
    /**
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
143 143
        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
144 144
        // move into RegistrationWorkflowStateMachine
145 145
        TransactionStatus txStatus = getRepo().startTransaction();
146
        long identifier = System.currentTimeMillis();
147 146

  
148 147
        Identifier<String> identifiers = minter.mint();
149 148
        if(identifiers.getIdentifier() == null){
......
322 321
    protected void configureTaxonNameEditor(TaxonNamePopupEditor popup) {
323 322
        popup.enableMode(TaxonNamePopupEditorMode.suppressReplacementAuthorshipData);
324 323
        popup.enableMode(TaxonNamePopupEditorMode.nomenclaturalReferenceSectionEditingOnly);
324
        popup.enableMode(TaxonNamePopupEditorMode.requireNomenclaturalReference);
325 325
    }
326 326

  
327 327
    /**
......
582 582
                Stack<EditorActionContext>context = ((AbstractPopupEditor)event.getSourceView()).getEditorActionContext();
583 583
                EditorActionContext rootContext = context.get(0);
584 584
                if(rootContext.getParentView().equals(getView())){
585
                    Registration blockingRegistration = createNewRegistrationForName(event.getEntityId());
585 586
                    TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity();
586
                    TaxonName newName = getRepo().getNameService().load(event.getEntityId(), Arrays.asList("$", "registrations"));
587
                    Registration blockingRegistration = Registration.NewInstance();
588
                    blockingRegistration = getRepo().getRegistrationService().save(blockingRegistration);
589
                    blockingRegistration.setName(newName);
590 587
                    Registration registration = getRepo().getRegistrationService().load(regReference.getId(), Arrays.asList("$", "blockedBy"));
591 588
                    registration.getBlockedBy().add(blockingRegistration);
592 589
                    getRepo().getRegistrationService().saveOrUpdate(registration);
593 590
                    logger.debug("Blocking registration created");
594 591
                } else {
595
                    throw new RuntimeException("huuu?");
592
                    logger.debug("Nn blocking registration, since a new name for a new registration has been created");
596 593
                }
597 594
            }
598 595
            if(workingset.getRegistrationDTOs().stream().anyMatch(reg ->
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
186 186
        addNewNameRegistrationButton = new Button("new name");
187 187
        addNewNameRegistrationButton.setDescription("A name which is newly published in this publication.");
188 188
        addNewNameRegistrationButton.addClickListener(
189
                e -> getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, this))
190
                );
189
                e -> getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, this)));
191 190

  
192 191
        addExistingNameButton = new Button("existing name:");
193 192
        addExistingNameButton.setDescription("A name which was previously published in a earlier publication.");
src/main/java/eu/etaxonomy/vaadin/mvp/AbstractPopupEditor.java
652 652
     * @param context the context to set
653 653
     */
654 654
    public void setParentEditorActionContext(Stack<EditorActionContext> context) {
655
        this.context.addAll(context);
655
        if(context != null){
656
            this.context.addAll(context);
657
        }
656 658
    }
657 659

  
658 660
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)