Project

General

Profile

Actions

task #8456

closed

FieldUnitDTO: remove newInstanceMethod

Added by Andreas Kohlbecker over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
New
Assignee:
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal

Description

copied from #8414

FieldUnitDTO providing a newInstance method. This has to be removed:

    /**
     * @param fieldUnit
     */
    public FieldUnitDTO(FieldUnit fieldUnit) {
        super(fieldUnit);
    }


    public static FieldUnitDTO newInstance(FieldUnit fieldUnit){
        FieldUnitDTO fieldUnitDto = new FieldUnitDTO(fieldUnit);
        if (fieldUnit.getGatheringEvent() != null){
            fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        }
        fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
        fieldUnitDto.setListLabel(fieldUnit.getTitleCache());

        return fieldUnitDto;

    }

is this by purpose? To me this looks like an error....

maybe this can be included into the constructor.

OccurrenceServiceImpl.assembleFieldUnitDTO(..) is using the constructor and adds the gathering event to the dto which is done in the newInstance method. --> TODO: needs review and harmonization (I think the newInstance Method should be removed completely as it causes confusion)


Related issues

Related to EDIT - task #8425: FieldUnitDTO: remove taxonRelatedDerivedUnitsClosedKatja Luther

Actions
Copied from EDIT - task #8414: occurrence controller code cleaning and harmonizationClosedAndreas Kohlbecker

Actions
Actions #1

Updated by Andreas Kohlbecker over 4 years ago

  • Related to task #8457: FieldUnitDTO: remove taxonRelatedDerivedUnits added
Actions #2

Updated by Andreas Kohlbecker over 4 years ago

  • Copied from task #8414: occurrence controller code cleaning and harmonization added
Actions #3

Updated by Andreas Kohlbecker over 4 years ago

  • Related to deleted (task #8457: FieldUnitDTO: remove taxonRelatedDerivedUnits)
Actions #4

Updated by Andreas Kohlbecker over 4 years ago

  • Related to task #8425: FieldUnitDTO: remove taxonRelatedDerivedUnits added
Actions #5

Updated by Andreas Kohlbecker over 4 years ago

  • Tracker changed from bug to task
Actions #6

Updated by Andreas Müller over 4 years ago

  • Assignee changed from Andreas Müller to Katja Luther
  • Target version changed from Unassigned CDM tickets to Release 5.10

Passing this ticket to Katja or Patrick as I never worked on/with this class.

Note: syntax of the method name is also not according to our standards. If it stays we should call it "NewInstance"

Actions #7

Updated by Katja Luther over 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50
Actions #8

Updated by Katja Luther over 4 years ago

  • Assignee changed from Katja Luther to Patrick Plitzner
  • % Done changed from 50 to 0

please review

Actions #9

Updated by Patrick Plitzner over 4 years ago

  • Status changed from Resolved to Feedback
  • Assignee changed from Patrick Plitzner to Katja Luther
  • % Done changed from 0 to 90

looks fine. Only on question: Why did you remove the null check when creating the GatheringEvent -> https://dev.e-taxonomy.eu/redmine/projects/edit/repository/revisions/ed34f59fbc07b3029f7c6f939d2108fc324a7d08/diff

before:

        if (fieldUnit.getGatheringEvent() != null){
            fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        }
        fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
        fieldUnitDto.setListLabel(fieldUnit.getTitleCache());

after:

    public FieldUnitDTO(FieldUnit fieldUnit) {
        super(fieldUnit);
        gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        setRecordBase(fieldUnit.getRecordBasis().getMessage());
        setListLabel(fieldUnit.getTitleCache());
    }
Actions #10

Updated by Katja Luther over 4 years ago

Patrick Plitzner wrote:

looks fine. Only on question: Why did you remove the null check when creating the GatheringEvent -> https://dev.e-taxonomy.eu/redmine/projects/edit/repository/revisions/ed34f59fbc07b3029f7c6f939d2108fc324a7d08/diff

before:

      if (fieldUnit.getGatheringEvent() != null){
          fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
      }
      fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
      fieldUnitDto.setListLabel(fieldUnit.getTitleCache());

after:

    public FieldUnitDTO(FieldUnit fieldUnit) {
        super(fieldUnit);
        gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        setRecordBase(fieldUnit.getRecordBasis().getMessage());
        setListLabel(fieldUnit.getTitleCache());
    }

the null check is now in the gatheringEventDto

Actions #11

Updated by Patrick Plitzner over 4 years ago

Katja Luther wrote:

the null check is now in the gatheringEventDto

The parameter gathering is not checked in the newInstance() method.

  public static GatheringEventDTO newInstance(GatheringEvent gathering){
        GatheringEventDTO dto = new GatheringEventDTO();
        gathering = HibernateProxyHelper.deproxy(gathering);
        if (gathering.getLocality() != null){

That code woul fail if gathering was null.

Actions #12

Updated by Katja Luther over 4 years ago

Katja Luther wrote:

Patrick Plitzner wrote:

looks fine. Only on question: Why did you remove the null check when creating the GatheringEvent -> https://dev.e-taxonomy.eu/redmine/projects/edit/repository/revisions/ed34f59fbc07b3029f7c6f939d2108fc324a7d08/diff

before:

        if (fieldUnit.getGatheringEvent() != null){
            fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        }
        fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
        fieldUnitDto.setListLabel(fieldUnit.getTitleCache());

after:

    public FieldUnitDTO(FieldUnit fieldUnit) {
        super(fieldUnit);
        gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        setRecordBase(fieldUnit.getRecordBasis().getMessage());
        setListLabel(fieldUnit.getTitleCache());
    }

the null check is now in the gatheringEventDto

do you have the actual code??

in my repository it looks like this:

public FieldUnitDTO(FieldUnit fieldUnit) {
        super(fieldUnit);
        if (fieldUnit.getGatheringEvent() != null){
            gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
        }
        setRecordBase(fieldUnit.getRecordBasis().getMessage());
        setListLabel(fieldUnit.getTitleCache());
    }
Actions #13

Updated by Katja Luther over 4 years ago

sorry I missed to add the last commit to this ticket.

Actions #14

Updated by Katja Luther over 4 years ago

  • Status changed from Feedback to Resolved
  • Assignee changed from Katja Luther to Patrick Plitzner
Actions #15

Updated by Patrick Plitzner over 4 years ago

  • Status changed from Resolved to Closed
  • Assignee changed from Patrick Plitzner to Katja Luther
  • % Done changed from 90 to 100

Katja Luther wrote:

sorry I missed to add the last commit to this ticket.

Yes, I just realized that, too.

cdmlib|a853ae404e985fb1a72c7f1ea1561c01424f603b is missing in this ticket

Actions

Also available in: Atom PDF