Project

General

Profile

« Previous | Next » 

Revision 9dc896c9

Added by Andreas Müller almost 7 years ago

fix #6368 rename table and class TaxonNameBase

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/namecatalogue/NameInformation.java
9 9
import eu.etaxonomy.cdm.model.common.Language;
10 10
import eu.etaxonomy.cdm.model.name.NameRelationship;
11 11
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
12
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
12
import eu.etaxonomy.cdm.model.name.TaxonName;
13 13
import eu.etaxonomy.cdm.model.reference.Reference;
14 14
import eu.etaxonomy.cdm.model.taxon.Taxon;
15 15
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
16 16
import eu.etaxonomy.cdm.remote.dto.common.RemoteResponse;
17 17

  
18 18
public class NameInformation implements RemoteResponse {
19
	
19

  
20 20
	private NameInformation.NameInformationRequest request;
21 21
	private NameInformation.NameInformationResponse response;
22
	
22

  
23 23
	public NameInformation() {
24
		
24

  
25 25
	}
26 26

  
27 27
	public void setRequest(String nameUuid) {
28 28
		request = new NameInformation.NameInformationRequest();
29 29
		request.setNameUuid(nameUuid);
30 30
	}
31
	
31

  
32 32
	public void setResponse(String title,
33 33
			String name,
34
			String rank, 
34
			String rank,
35 35
			Set<NomenclaturalStatus> nomenclatureStatus,
36 36
			String citation,
37 37
			Set<NameRelationship> relationsFromThisName,
......
41 41
		response.setTitle(title);
42 42
		response.setName(name);
43 43
		response.setRank(rank);
44
		
44

  
45 45
		// set status list
46 46
		Iterator it = nomenclatureStatus.iterator();
47
		System.out.println("NStatus Size : " + nomenclatureStatus.size());	
47
		System.out.println("NStatus Size : " + nomenclatureStatus.size());
48 48
		while(it.hasNext()) {
49 49
			NomenclaturalStatus ns = (NomenclaturalStatus)it.next();
50 50
			response.addToNomenclatureStaus(ns.toString());
51
		}		
51
		}
52 52
		// set citation
53 53
		response.setCitation(citation);
54 54

  
55 55
		addToResponseNameRelationships(relationsFromThisName, relationsToThisName);
56 56
		addToResponseTaxonInfo(taxonBases);
57
		
57

  
58 58
	}
59
	
59

  
60 60

  
61 61
	private void addToResponseNameRelationships(Set<NameRelationship> relationsFromThisName,
62 62
				Set<NameRelationship> relationsToThisName) {
......
64 64
		String typeString = "";
65 65
		String relatednameCache = "";
66 66
		String relatedCitation = "";
67
		
67

  
68 68
		Iterator it = relationsFromThisName.iterator();
69
		
69

  
70 70
		while(it.hasNext()) {
71 71
			typeString = "";
72 72
			relatednameCache = "";
73 73
			relatedCitation = "";
74
			
74

  
75 75
			NameRelationship nr = (NameRelationship)it.next();
76 76
			if(nr.getType() != null) {
77 77
				typeString = nr.getType()
78 78
				        .getRepresentation(Language.DEFAULT())
79 79
                        .getLabel();
80 80
			}
81
			TaxonNameBase tnbRelatedTo = nr.getToName();
81
			TaxonName tnbRelatedTo = nr.getToName();
82 82
			if(tnbRelatedTo != null) {
83 83
			    System.out.println("tnbRelatedTo not null");
84 84
				relatednameCache = tnbRelatedTo.getTitleCache();
......
88 88
				}
89 89
			}
90 90
			response.addNameRelationships(typeString,
91
					relatednameCache, 
91
					relatednameCache,
92 92
					relatedCitation);
93
		}	
93
		}
94 94
		// set name to relationship
95 95
		it = relationsToThisName.iterator();
96
		
96

  
97 97
		while(it.hasNext()) {
98 98
			typeString = "";
99 99
			relatednameCache = "";
100 100
			relatedCitation = "";
101
			
101

  
102 102
			NameRelationship nr = (NameRelationship)it.next();
103 103
			if(nr.getType() != null) {
104 104
				typeString = nr.getType()
105 105
				        .getInverseRepresentation(Language.DEFAULT())
106 106
                        .getLabel();
107 107
			}
108
			
109
			TaxonNameBase tnbRelatedFrom = nr.getFromName();
108

  
109
			TaxonName tnbRelatedFrom = nr.getFromName();
110 110
			if(tnbRelatedFrom != null) {
111 111
			    System.out.println("tnbRelatedTo not null");
112 112
				relatednameCache = tnbRelatedFrom.getTitleCache();
......
116 116
				}
117 117
			}
118 118
			response.addNameRelationships(typeString,
119
					relatednameCache, 
119
					relatednameCache,
120 120
					relatedCitation);
121
		}	
122
		
121
		}
122

  
123 123
	}
124
	
124

  
125 125
	public void addToResponseTaxonInfo(Set<TaxonBase> taxonBases) {
126
		Iterator it = taxonBases.iterator();		
126
		Iterator it = taxonBases.iterator();
127 127
		while(it.hasNext()) {
128 128
			TaxonBase tb = (TaxonBase)it.next();
129
			response.addToTaxonUuids(tb.getUuid().toString());	
129
			response.addToTaxonUuids(tb.getUuid().toString());
130 130
			if(tb.isInstanceOf(Taxon.class) && tb.getLsid() != null) {
131 131
				response.addToTaxonLsids(tb.getLsid().toString());
132 132
			}
133
			
134
		}			
133

  
134
		}
135 135
	}
136
	
136

  
137 137

  
138 138
	public NameInformation.NameInformationResponse getResponse() {
139 139
		return response;
140 140
	}
141
	
141

  
142 142
	public NameInformation.NameInformationRequest getRequest() {
143 143
		return this.request;
144 144
	}
145
	
145

  
146 146
	public class NameInformationRequest {
147 147
		private String nameUuid;
148
		
148

  
149 149
		public NameInformationRequest() {
150 150
			this.nameUuid = "";
151 151
		}
152
		
152

  
153 153
		public void setNameUuid(String nameUuid) {
154 154
			this.nameUuid = nameUuid;
155 155
		}
156
		
156

  
157 157
		public String getNameUuid() {
158 158
			return this.nameUuid;
159 159
		}
160
		
161
		
160

  
161

  
162 162
	}
163
	
163

  
164 164
	public class NameInformationResponse {
165 165
		private String title;
166 166
		private String name;
......
171 171
		private Set<String> taxonUuids;
172 172
		private Set<String> taxonLsids;
173 173

  
174
		
174

  
175 175
		public NameInformationResponse() {
176 176
			title = "";
177 177
			name = "";
......
181 181
			nameRelationships = new ArrayList<NameInformation.NameInformationResponse.NameRelationshipInfo>();
182 182
			taxonUuids = new HashSet<String>();
183 183
			taxonLsids = new HashSet<String>();
184
			
184

  
185 185
		}
186
		
186

  
187 187
		public void setTitle(String title) {
188 188
			this.title = title;
189 189
		}
190
		
190

  
191 191
		public String getTitle() {
192 192
			return this.title;
193 193
		}
194
		
194

  
195 195
		public void setName(String name) {
196 196
			this.name = name;
197 197
		}
198
		
198

  
199 199
		public String getName() {
200 200
			return this.name;
201 201
		}
202
		
202

  
203 203
		public void setRank(String rank) {
204 204
			this.rank = rank;
205 205
		}
206
		
206

  
207 207
		public String getRank() {
208 208
			return this.rank;
209 209
		}
210
		
210

  
211 211
		public void addToNomenclatureStaus(String nomenclatureStatus) {
212 212
			this.nomenclatureStatus.add(nomenclatureStatus);
213 213
		}
214
		
214

  
215 215
		public List<String> getNomenclatureStatus() {
216 216
			return this.nomenclatureStatus;
217 217
		}
218
		
218

  
219 219
		public void setCitation(String citation) {
220 220
			this.citation = citation;
221 221
		}
222
		
222

  
223 223
		public String getCitation() {
224
			return this.citation;					
224
			return this.citation;
225 225
		}
226
		
226

  
227 227
		public void addNameRelationships(String type, String relatedName, String citation) {
228
			NameInformation.NameInformationResponse.NameRelationshipInfo nr = 
228
			NameInformation.NameInformationResponse.NameRelationshipInfo nr =
229 229
					new NameInformation.NameInformationResponse.NameRelationshipInfo();
230 230
			nr.setRelationInfo(type, relatedName, citation);
231 231
			nameRelationships.add(nr);
232 232
		}
233
		
233

  
234 234
		public List<NameInformation.NameInformationResponse.NameRelationshipInfo> getNameRelationships() {
235 235
			return nameRelationships;
236 236
		}
237
		
237

  
238 238
		public void addToTaxonUuids(String taxonUuid) {
239 239
			taxonUuids.add(taxonUuid);
240 240
		}
241
		
241

  
242 242
		public Set<String> getTaxonUuids() {
243 243
			return this.taxonUuids;
244 244
		}
245
		
245

  
246 246
		public void addToTaxonLsids(String lsid) {
247 247
			taxonLsids.add(lsid);
248 248
		}
249
		
249

  
250 250
		public Set<String> getTaxonLsids() {
251 251
			return this.taxonLsids;
252 252
		}
253
		
253

  
254 254
		public class NameRelationshipInfo {
255 255
			private String type;
256 256
			private String relatedName;
257 257
			private String citation;
258
				
259 258

  
260
			
259

  
260

  
261 261
			public NameRelationshipInfo() {
262
				
262

  
263 263
			}
264
			
264

  
265 265
			public void setRelationInfo(String type, String relatedName, String citation) {
266 266
				this.type = type;
267 267
				this.relatedName = relatedName;
268
				this.citation = citation;			
268
				this.citation = citation;
269 269
			}
270
			
270

  
271 271
			public String getType() {
272 272
				return this.type;
273 273
			}
274
			
274

  
275 275
			public String getRelatedName() {
276 276
				return this.relatedName;
277 277
			}
278
			
278

  
279 279
			public String getCitation() {
280
				return this.citation;				
280
				return this.citation;
281 281
			}
282
			
282

  
283 283

  
284 284
		}
285 285
	}

Also available in: Unified diff