Project

General

Profile

Revision c31ff29d

IDc31ff29de8fe22a4989ab30bd4db2e3393be18e0
Parent 135547e5
Child c6716d5c

Added by Katja Luther about 1 year ago

kindOfUnit for all derivates not only for field units

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
1175 1175
        DerivedUnitFacade derivedUnitFacade = DerivedUnitFacade.NewInstance(type);
1176 1176
        derivedUnitFacade.setFieldUnit(state.getFieldUnit(state.getDataHolder().getFieldNumber()));
1177 1177
        derivedUnitFacade.setKindOfUnit(kindOfUnit);
1178
        derivedUnitFacade.setDerivedUnitKindOfUnit(kindOfUnit);
1178 1179
        return derivedUnitFacade;
1179 1180
    }
1180 1181

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java
99 99
        return mv;
100 100
    }
101 101

  
102
    @RequestMapping(value = {"fieldObjectMedia"}, method = RequestMethod.GET)
103
    public ModelAndView doGetFieldObjectMedia(
102
    @RequestMapping(value = {"fieldObjectMediaDTO"}, method = RequestMethod.GET)
103
    public ModelAndView doGetFieldObjectMediaDTO(
104 104
        @PathVariable("uuid") UUID occurrenceUuid,
105 105
        HttpServletRequest request,
106 106
        HttpServletResponse response) throws IOException {
107 107

  
108 108
        logger.info("doGetFieldObjectMedia() - " + request.getRequestURI());
109 109
        ModelAndView mv = new ModelAndView();
110
        DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{
111
                "fieldObjectMedia", "fieldObjectMedia.title"}));
112
        SpecimenOrObservationBase sob = service.load(occurrenceUuid, null);
110
//        DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{
111
//                "fieldObjectMedia", "fieldObjectMedia.title"}));
112
        SpecimenOrObservationBase sob = service.load(occurrenceUuid, Arrays.asList(new String []{"descriptions", "kindOfUnit"}));
113 113
        FieldUnitDTO dto;
114 114
        if (sob instanceof FieldUnit){
115 115
            dto = FieldUnitDTO.newInstance((FieldUnit)sob);
......
119 119
        return mv;
120 120
    }
121 121

  
122
    @RequestMapping(value = {"fieldObjectMedia"}, method = RequestMethod.GET)
123
    public ModelAndView doGetFieldObjectMedia(
124
        @PathVariable("uuid") UUID occurrenceUuid,
125
        HttpServletRequest request,
126
        HttpServletResponse response) throws IOException {
127

  
128
        logger.info("doGetFieldObjectMedia() - " + request.getRequestURI());
129
        ModelAndView mv = new ModelAndView();
130
        DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{
131
                "fieldObjectMedia", "fieldObjectMedia.title"}));
132

  
133
        mv.addObject(duf.getFieldObjectMedia());
134

  
135
        return mv;
136
    }
137

  
138

  
122 139
// TODO
123 140
    //@RequestMapping(method = RequestMethod.GET, value = "{uuid}/collectingareas")
124 141
    @RequestMapping(
......
194 211
                logger.error(e); //TODO ...
195 212
            }
196 213
        } else {
214

  
197 215
            HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response);
198 216
        }
199 217
        return null;
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/facade/DerivedUnitFacade.java
1853 1853
	    }
1854 1854
	}
1855 1855

  
1856
//    public void setDerivedUnitKindOfUnit(DefinedTerm kindOfUnit) {
1857
//        testDerivedUnit();
1858
//
1859
//        baseUnit().setKindOfUnit(kindOfUnit);
1860
//    }
1856
    public void setDerivedUnitKindOfUnit(DefinedTerm kindOfUnit) {
1857
        testDerivedUnit();
1858

  
1859
        baseUnit().setKindOfUnit(kindOfUnit);
1860
    }
1861 1861

  
1862 1862

  
1863 1863
	// field unit
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
1045 1045
        //from which this DerivedUnit was derived until all FieldUnits are found.
1046 1046
        List<SpecimenOrObservationBase> specimens = new ArrayList<>();
1047 1047
        List<String> propertyPaths = new ArrayList<>();
1048

  
1048 1049
        propertyPaths.add("descriptions.elements.media.title");
1050
        propertyPaths.add("kindOfUnit");
1049 1051

  
1050 1052
        specimens = dao.findOriginalsForDerivedUnit(derivedUnitDTO.getUuid(), propertyPaths);
1051 1053

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/VersionableServiceBase.java
14 14
import java.util.Set;
15 15
import java.util.UUID;
16 16

  
17
import org.hibernate.ObjectDeletedException;
17 18
import org.hibernate.envers.query.criteria.AuditCriterion;
18 19
import org.springframework.beans.factory.annotation.Autowired;
19 20
import org.springframework.transaction.annotation.Transactional;
......
78 79
    public DeleteResult isDeletable(UUID baseUUID, DeleteConfiguratorBase config){
79 80
    	DeleteResult result = new DeleteResult();
80 81
    	T base = this.find(baseUUID);
82
    	if (base == null){
83
    	    result.setAbort();
84
    	    result.addException(new ObjectDeletedException("The object was already deleted.", baseUUID, null));
85
    	}
81 86
    	Set<CdmBase> references = commonService.getReferencingObjectsForDeletion(base);
82 87
    	if (references != null){
83 88
	    	result.addRelatedObjects(references);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDTO.java
27 27
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
28 28
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
29 29
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
30
import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
30
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
31 31
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
32 32
import eu.etaxonomy.cdm.ref.TypedEntityReference;
33
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
34 33

  
35 34

  
36 35
/**
......
55 54
    private boolean hasSpecimenScan;
56 55

  
57 56
    private String recordBase;
57
    private String kindOfUnit;
58 58
    private CollectionDTO collection;
59 59
    private String catalogNumber;
60 60
    private String collectorsNumber;
......
72 72
    public DerivateDTO(SpecimenOrObservationBase specimenOrObservation) {
73 73
        super(specimenOrObservation.getClass(), specimenOrObservation.getUuid(), specimenOrObservation.getTitleCache());
74 74
        addMedia(specimenOrObservation);
75
        if (specimenOrObservation.getKindOfUnit() != null){
76
            setKindOfUnit(specimenOrObservation.getKindOfUnit().getTitleCache());
77
        }
78
        if (specimenOrObservation instanceof DerivedUnit){
79
            DerivedUnit derivedUnit = (DerivedUnit)specimenOrObservation;
80
            if (derivedUnit.getSpecimenTypeDesignations() != null){
81
                setSpecimenTypeDesignations(derivedUnit.getSpecimenTypeDesignations());
82
            }
83
        }
75 84
    }
76 85
    public String getTitleCache() {
77 86
        return getLabel();
......
338 347
    }
339 348

  
340 349
    public void addMedia(SpecimenOrObservationBase specimenOrObservation){
341
        Set<DescriptionBase<IIdentifiableEntityCacheStrategy<FieldUnit>>> descriptions = specimenOrObservation.getDescriptions();
350
        Set<DescriptionBase> descriptions = specimenOrObservation.getSpecimenDescriptionImageGallery();
342 351
        for (DescriptionBase desc : descriptions){
343 352
            if (desc instanceof SpecimenDescription){
344 353
                SpecimenDescription specimenDesc = (SpecimenDescription)desc;
345
                if (specimenDesc.isImageGallery()){
346
                    for (DescriptionElementBase element : specimenDesc.getElements()){
347
                        if (element.isInstanceOf(TextData.class)&& element.getFeature().equals(Feature.IMAGE())) {
348
                            for (Media media :element.getMedia()){
349
                                for (MediaRepresentation rep :media.getRepresentations()){
350
                                    for(MediaRepresentationPart p : rep.getParts()){
351
                                        if(p.getUri() != null){
352
                                            MediaDTO dto = new MediaDTO(media.getUuid());
353
                                            dto.setUri(p.getUri().toString());
354
                                            this.getListOfMedia().add(dto);
355
                                        }
354
                for (DescriptionElementBase element : specimenDesc.getElements()){
355
                    if (element.isInstanceOf(TextData.class)&& element.getFeature().equals(Feature.IMAGE())) {
356
                        for (Media media :element.getMedia()){
357
                            for (MediaRepresentation rep :media.getRepresentations()){
358
                                for(MediaRepresentationPart p : rep.getParts()){
359
                                    if(p.getUri() != null){
360
                                        MediaDTO dto = new MediaDTO(media.getUuid());
361
                                        dto.setUri(p.getUri().toString());
362
                                        this.getListOfMedia().add(dto);
356 363
                                    }
357 364
                                }
358 365
                            }
......
362 369
            }
363 370
        }
364 371
    }
372
    public String getKindOfUnit() {
373
        return kindOfUnit;
374
    }
375
    public void setKindOfUnit(String kindOfUnit) {
376
        this.kindOfUnit = kindOfUnit;
377
    }
365 378

  
366 379

  
367 380
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/FieldUnitDTO.java
15 15
	private String date;
16 16

  
17 17
	private boolean hasType;
18

  
19

  
20
	private String kindOfUnit;
21 18
	private List<UUID> taxonRelatedDerivedUnits = new ArrayList<>();
22 19

  
23 20

  
......
36 33

  
37 34
    public static FieldUnitDTO newInstance(FieldUnit fieldUnit){
38 35
	    FieldUnitDTO fieldUnitDto = new FieldUnitDTO(fieldUnit);
39
	    fieldUnitDto.kindOfUnit = fieldUnit.getKindOfUnit().getTitleCache();
40 36
	    fieldUnitDto.gatheringEvent = GatheringEventDTO.newInstance(fieldUnit.getGatheringEvent());
41 37
	    fieldUnitDto.setRecordBase(fieldUnit.getRecordBasis().getMessage());
42 38
	    fieldUnitDto.setListLabel(fieldUnit.getTitleCache());
......
156 152
        this.hasType = hasType;
157 153
    }
158 154

  
159

  
160
    public String getKindOfUnit() {
161
        return kindOfUnit;
162
    }
163
    public void setKindOfUnit(String kindOfUnit) {
164
        this.kindOfUnit = kindOfUnit;
165
    }
166

  
167 155
    public GatheringEventDTO getGatheringEvent() {
168 156
        return gatheringEvent;
169 157
    }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)