Revision 3baf1767
Added by Andreas Kohlbecker almost 5 years ago
src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java | ||
---|---|---|
63 | 63 |
"typeDesignations.typeName.$", |
64 | 64 |
"typeDesignations.citation", |
65 | 65 |
"typeDesignations.citation.authorship.$", |
66 |
"typeDesignations.annotations", // needed for AnnotatableEntity.clone() in DerivedUnitConverter.copyPropertiesTo |
|
67 |
"typeDesignations.markers", // needed for AnnotatableEntity.clone() in DerivedUnitConverter.copyPropertiesTo |
|
68 |
"typeDesignations.registrations", // DerivedUnitConverter.copyPropertiesTo(TARGET n) |
|
69 |
|
|
66 | 70 |
// name |
67 | 71 |
"name.$", |
68 | 72 |
"name.nomenclaturalReference.authorship.$", |
src/main/java/eu/etaxonomy/cdm/service/SpecimenTypeDesignationWorkingSetServiceImpl.java | ||
---|---|---|
133 | 133 |
FieldUnit fieldUnit = FieldUnit.NewInstance(); |
134 | 134 |
GatheringEvent gatheringEvent = GatheringEvent.NewInstance(); |
135 | 135 |
fieldUnit.setGatheringEvent(gatheringEvent); |
136 |
repo.getOccurrenceService().save(fieldUnit); |
|
136 |
fieldUnit = (FieldUnit) repo.getOccurrenceService().save(fieldUnit);
|
|
137 | 137 |
|
138 | 138 |
VersionableEntity baseEntity = bean.getBaseEntity(); |
139 | 139 |
Set<TypeDesignationBase> typeDesignations = regDTO.getTypeDesignationsInWorkingSet( |
... | ... | |
182 | 182 |
|
183 | 183 |
Session session = repo.getSession(); |
184 | 184 |
|
185 |
// PersistentContextAnalyzer regAnalyzer = new PersistentContextAnalyzer(dto.getOwner(), session); |
|
186 |
// regAnalyzer.printEntityGraph(System.out); |
|
187 |
// regAnalyzer.printCopyEntities(System.out); |
|
188 |
|
|
189 | 185 |
session.merge(dto.getOwner()); |
190 | 186 |
session.flush(); |
191 | 187 |
|
192 | 188 |
// ------------------------ perform delete of removed SpecimenTypeDesignations |
189 |
// this step also includes the deletion of DerivedUnits which have been converted by |
|
190 |
// the DerivedUnitConverter in turn of a kindOfUnit change |
|
193 | 191 |
for(SpecimenTypeDesignation std : dto.deletedSpecimenTypeDesignations()){ |
194 | 192 |
deleteSpecimenTypeDesignation(dto, std); |
195 | 193 |
} |
196 |
session.flush(); |
|
197 | 194 |
} |
198 | 195 |
|
199 | 196 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationDTO.java | ||
---|---|---|
15 | 15 |
|
16 | 16 |
import eu.etaxonomy.cdm.api.utility.DerivedUnitConversionException; |
17 | 17 |
import eu.etaxonomy.cdm.api.utility.DerivedUnitConverter; |
18 |
import eu.etaxonomy.cdm.api.utility.DerivedUnitConverterFactory; |
|
19 | 18 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
20 | 19 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
21 | 20 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
... | ... | |
53 | 52 |
public class SpecimenTypeDesignationDTO { |
54 | 53 |
|
55 | 54 |
SpecimenTypeDesignation std; |
55 |
private DerivedUnit replacedTypeSpecimen; |
|
56 | 56 |
|
57 | 57 |
/** |
58 | 58 |
* @return the std |
... | ... | |
61 | 61 |
return std; |
62 | 62 |
} |
63 | 63 |
|
64 |
public DerivedUnit replacedTypeSpecimen(){ |
|
65 |
return replacedTypeSpecimen; |
|
66 |
} |
|
67 |
|
|
64 | 68 |
/** |
65 | 69 |
* Creates an new new instance of SpecimenTypeDesignationDTO which is backed up |
66 | 70 |
* by an newly instantiated <code>SpecimenTypeDesignation.typeSpecimen.derivedFrom.type</code> object graph. |
... | ... | |
103 | 107 |
Class<? extends DerivedUnit> currentType = typeSpecimen.getClass(); |
104 | 108 |
|
105 | 109 |
if(!requiredSpecimenType.equals(currentType)){ |
106 |
|
|
107 |
DerivedUnit convertedSpecimen; |
|
108 |
|
|
109 | 110 |
SpecimenOrObservationType convertToType = specimenOrObservationTypeFor(kindOfUnit); |
110 | 111 |
if(requiredSpecimenType.equals(MediaSpecimen.class)){ |
111 |
DerivedUnitConverter<MediaSpecimen> converter = DerivedUnitConverterFactory.createDerivedUnitConverter(typeSpecimen, MediaSpecimen.class);
|
|
112 |
convertedSpecimen = converter.convertTo((Class<MediaSpecimen>)requiredSpecimenType, convertToType);
|
|
112 |
DerivedUnitConverter<MediaSpecimen> converter = new DerivedUnitConverter<MediaSpecimen>(std);
|
|
113 |
std = converter.convertTo((Class<MediaSpecimen>)requiredSpecimenType, convertToType);
|
|
113 | 114 |
} else { |
114 | 115 |
if(currentType == MediaSpecimen.class){ |
115 | 116 |
MediaSpecimen mediaSpecimen = (MediaSpecimen)typeSpecimen; |
116 | 117 |
// set null to allow conversion |
117 | 118 |
mediaSpecimen.setMediaSpecimen(null); |
118 | 119 |
} |
119 |
DerivedUnitConverter<DerivedUnit> converter = DerivedUnitConverterFactory.createDerivedUnitConverter(typeSpecimen, DerivedUnit.class); |
|
120 |
convertedSpecimen = converter.convertTo((Class<DerivedUnit>)requiredSpecimenType, convertToType); |
|
120 |
DerivedUnitConverter<DerivedUnit> converter = new DerivedUnitConverter<DerivedUnit>(std); |
|
121 |
std = converter.convertTo((Class<DerivedUnit>)requiredSpecimenType, convertToType); |
|
122 |
} |
|
123 |
if(typeSpecimen.getId() != 0){ |
|
124 |
replacedTypeSpecimen = typeSpecimen; |
|
121 | 125 |
} |
122 | 126 |
|
123 |
std.setTypeSpecimen(convertedSpecimen); |
|
124 | 127 |
} |
125 | 128 |
} |
126 | 129 |
|
130 |
/** |
|
131 |
* |
|
132 |
* @return the total count of typeDesignations associated with the type specimen |
|
133 |
*/ |
|
134 |
public int getAssociatedTypeDesignationCount() { |
|
135 |
return std.getTypeSpecimen().getSpecimenTypeDesignations().size(); |
|
136 |
} |
|
137 |
|
|
127 | 138 |
|
128 | 139 |
/** |
129 | 140 |
* See constructor doc. |
src/main/java/eu/etaxonomy/cdm/vaadin/model/registration/SpecimenTypeDesignationWorkingSetDTO.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.model.location.Point; |
24 | 24 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
25 | 25 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
26 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
27 | 28 |
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent; |
28 | 29 |
import eu.etaxonomy.cdm.model.reference.Reference; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationDTORow.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 |
import java.util.List; |
|
12 | 13 |
|
13 | 14 |
import com.vaadin.server.Sizeable.Unit; |
14 | 15 |
import com.vaadin.ui.Component; |
... | ... | |
40 | 41 |
* |
41 | 42 |
* The fieldname must match the properties of the SpecimenTypeDesignationDTO |
42 | 43 |
*/ |
43 |
RowListSelect kindOfUnit = new RowListSelect(); |
|
44 |
TextField associatedTypeDesignationCount = new TextField(); |
|
45 |
RowListSelect kindOfUnit = new RowListSelect(); // position is IMPORTANT, see rowListSelectColumn() |
|
44 | 46 |
ListSelect typeStatus = new ListSelect(); |
45 | 47 |
ToOneRelatedEntityCombobox<eu.etaxonomy.cdm.model.occurrence.Collection> collection = |
46 | 48 |
new ToOneRelatedEntityCombobox<eu.etaxonomy.cdm.model.occurrence.Collection>(null, eu.etaxonomy.cdm.model.occurrence.Collection.class); |
... | ... | |
57 | 59 |
kindOfUnit.setRow(this); |
58 | 60 |
typeStatus.setRows(1); |
59 | 61 |
typeStatus.setRequired(true); |
62 |
|
|
60 | 63 |
accessionNumber.setWidth(100, Unit.PIXELS); |
61 | 64 |
preferredStableUri.setWidth(150, Unit.PIXELS); |
62 | 65 |
preferredStableUri.setConverter(new UriConverter()); |
... | ... | |
77 | 80 |
*/ |
78 | 81 |
public Component[] components() { |
79 | 82 |
Component[] components = new Component[]{ |
83 |
associatedTypeDesignationCount, |
|
80 | 84 |
kindOfUnit, typeStatus, |
81 | 85 |
collection, accessionNumber, |
82 | 86 |
preferredStableUri, |
83 | 87 |
mediaUri, mediaSpecimenReference, |
84 |
mediaSpecimenReferenceDetail, mediaSpecimenReferenceDetail
|
|
88 |
mediaSpecimenReferenceDetail |
|
85 | 89 |
}; |
86 | 90 |
addAll(Arrays.asList(components)); |
87 | 91 |
return components; |
88 | 92 |
} |
89 | 93 |
|
94 |
public static List<String> visibleFields() { |
|
95 |
List<String> visibleFields = Arrays.asList(new String[]{ |
|
96 |
"kindOfUnit", "typeStatus", |
|
97 |
"collection", "accessionNumber", |
|
98 |
"preferredStableUri", |
|
99 |
"mediaUri", "mediaSpecimenReference", |
|
100 |
"mediaSpecimenReferenceDetail" |
|
101 |
}); |
|
102 |
return visibleFields; |
|
103 |
} |
|
104 |
|
|
90 | 105 |
@Override |
91 | 106 |
public void updateRowItemsEnablement() { |
92 | 107 |
|
... | ... | |
95 | 110 |
boolean publishedImageType = kindOfUnitTerm != null && kindOfUnitTerm.equals(KindOfUnitTerms.PUBLISHED_IMAGE()); |
96 | 111 |
boolean unPublishedImageType = kindOfUnitTerm != null && kindOfUnitTerm.equals(KindOfUnitTerms.UNPUBLISHED_IMAGE()); |
97 | 112 |
|
98 |
mediaSpecimenReference.setEnabled(publishedImageType); |
|
99 |
mediaSpecimenReferenceDetail.setEnabled(publishedImageType); |
|
113 |
boolean kindOfUnitLocked = !associatedTypeDesignationCount.getValue().isEmpty() && Integer.valueOf(associatedTypeDesignationCount.getValue()) > 1; |
|
114 |
kindOfUnit.setEnabled(!kindOfUnitLocked); |
|
115 |
kindOfUnit.setDescription(kindOfUnitLocked ? |
|
116 |
"Can not be changed since the type specimen is associated with multiple type designations" : ""); |
|
117 |
mediaSpecimenReference.setEnabled(publishedImageType || unPublishedImageType); |
|
118 |
mediaSpecimenReferenceDetail.setEnabled(publishedImageType || unPublishedImageType); |
|
100 | 119 |
mediaUri.setEnabled(publishedImageType || unPublishedImageType); |
101 | 120 |
|
102 | 121 |
} |
103 | 122 |
|
123 |
/** |
|
124 |
* |
|
125 |
* @return the 0-based position index of the <code>kindOfUnit</code> field in this class |
|
126 |
* which are visible according to {@link #visibleFields()) |
|
127 |
*/ |
|
128 |
public static int rowListSelectColumn(){ |
|
129 |
return 0; |
|
130 |
} |
|
131 |
|
|
104 | 132 |
class RowListSelect extends ListSelect implements CollectionRowRepresentative { |
105 | 133 |
|
106 | 134 |
private static final long serialVersionUID = 3235653923633494213L; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetPopupEditor.java | ||
---|---|---|
169 | 169 |
// FIXME: can we use the Grid instead? |
170 | 170 |
typeDesignationsCollectionField = new ElementCollectionField<>( |
171 | 171 |
SpecimenTypeDesignationDTO.class, |
172 |
//getPresenter().specimenTypeDesignationDTOInstantiator(getBean()); |
|
173 | 172 |
SpecimenTypeDesignationDTORow.class |
174 | 173 |
); |
175 | 174 |
typeDesignationsCollectionField.withCaption("Types"); |
176 | 175 |
typeDesignationsCollectionField.getLayout().setSpacing(false); |
177 | 176 |
typeDesignationsCollectionField.getLayout().setColumns(3); |
178 | 177 |
|
178 |
typeDesignationsCollectionField.setVisibleProperties(SpecimenTypeDesignationDTORow.visibleFields()); |
|
179 |
|
|
179 | 180 |
typeDesignationsCollectionField.setPropertyHeader("accessionNumber", "Access. num."); |
180 | 181 |
typeDesignationsCollectionField.setPropertyHeader("preferredStableUri", "Stable URI"); |
181 | 182 |
typeDesignationsCollectionField.setPropertyHeader("mediaSpecimenReference", "Image reference"); |
... | ... | |
274 | 275 |
super.afterItemDataSourceSet(); |
275 | 276 |
GridLayout gridLayout = this.typeDesignationsCollectionField.getLayout(); |
276 | 277 |
for(int rowIndex = 1; rowIndex < gridLayout.getRows(); rowIndex++){ // first row is header |
277 |
Component item = gridLayout.getComponent(0, rowIndex);
|
|
278 |
Component item = gridLayout.getComponent(SpecimenTypeDesignationDTORow.rowListSelectColumn(), rowIndex);
|
|
278 | 279 |
((CollectionRowRepresentative)item).updateRowItemsEnabledStates(); |
279 | 280 |
} |
280 | 281 |
updateAllowDelete(); |
Also available in: Unified diff
fix #7353 SpecimenTypedesignationsWorkingsetEditor: adapting to changes in DerivedUnitConverter and blockig kindOfUnit changes in case of multiple typeDesignations per specimen