2 * This document is a part of the source code and related artifacts
\r
3 * for CollectionSpace, an open source collections management system
\r
4 * for museums and related institutions:
\r
6 * http://www.collectionspace.org
\r
7 * http://wiki.collectionspace.org
\r
9 * Copyright (c)) 2009 Regents of the University of California
\r
11 * Licensed under the Educational Community License (ECL), Version 2.0.
\r
12 * You may not use this file except in compliance with this License.
\r
14 * You may obtain a copy of the ECL 2.0 License at
\r
15 * https://source.collectionspace.org/collection-space/LICENSE.txt
\r
17 * Unless required by applicable law or agreed to in writing, software
\r
18 * distributed under the License is distributed on an "AS IS" BASIS,
\r
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
20 * See the License for the specific language governing permissions and
\r
21 * limitations under the License.
\r
24 package org.collectionspace.services.person.client.sample;
\r
26 import java.util.ArrayList;
\r
27 import java.util.Arrays;
\r
28 import java.util.HashMap;
\r
29 import java.util.List;
\r
30 import java.util.Map;
\r
32 import javax.ws.rs.core.MediaType;
\r
33 import javax.ws.rs.core.MultivaluedMap;
\r
34 import javax.ws.rs.core.Response;
\r
36 import org.apache.log4j.BasicConfigurator;
\r
37 import org.collectionspace.services.PersonJAXBSchema;
\r
38 import org.collectionspace.services.client.PersonAuthorityClient;
\r
39 import org.collectionspace.services.client.PersonAuthorityClientUtils;
\r
40 import org.collectionspace.services.client.PoxPayloadOut;
\r
41 import org.collectionspace.services.client.test.ServiceRequestType;
\r
42 import org.collectionspace.services.person.PersonauthoritiesCommon;
\r
43 import org.collectionspace.services.person.PersonauthoritiesCommonList;
\r
44 import org.collectionspace.services.person.PersonsCommon;
\r
45 import org.collectionspace.services.person.PersonsCommonList;
\r
46 import org.jboss.resteasy.client.ClientResponse;
\r
47 import org.jboss.resteasy.plugins.providers.multipart.InputPart;
\r
48 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
\r
49 import org.slf4j.Logger;
\r
50 import org.slf4j.LoggerFactory;
\r
53 * PersonAuthority Sample, carries out tests against a
\r
54 * deployed and running PersonAuthority Service.
\r
56 * $LastChangedRevision: 1055 $
\r
57 * $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
\r
59 public class Sample {
\r
60 private static final Logger logger =
\r
61 LoggerFactory.getLogger(Sample.class);
\r
63 // Instance variables specific to this test.
\r
64 private PersonAuthorityClient client = new PersonAuthorityClient();
\r
65 final String SERVICE_PATH_COMPONENT = "persons";
\r
66 final String ITEM_SERVICE_PATH_COMPONENT = "items";
\r
69 // ---------------------------------------------------------------
\r
71 // ---------------------------------------------------------------
\r
73 public void createPersonAuthority(String personAuthorityName,
\r
74 List<Map<String, String>> personMaps ) {
\r
76 // Expected status code: 201 Created
\r
77 int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
\r
78 // Type of service request being tested
\r
79 ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
\r
81 logger.info("Import: Create personAuthority: \"" + personAuthorityName +"\"");
\r
84 String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
\r
85 String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix);//TODO: Laramie20100728 temp fix was personAuthorityName, false
\r
86 String fullPersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix); //TODO: Laramie20100728 temp fix was personAuthorityName, true
\r
87 PoxPayloadOut multipart =
\r
88 PersonAuthorityClientUtils.createPersonAuthorityInstance(
\r
89 personAuthorityName, fullPersonRefName, client.getCommonPartName() );
\r
90 ClientResponse<Response> res = client.create(multipart);
\r
92 int statusCode = res.getStatus();
\r
94 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
95 throw new RuntimeException("Could not create enumeration: \""+personAuthorityName
\r
96 +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
98 if(statusCode != EXPECTED_STATUS_CODE) {
\r
99 throw new RuntimeException("Unexpected Status when creating enumeration: \""
\r
100 +personAuthorityName +"\", Status:"+ statusCode);
\r
103 // Store the ID returned from this create operation
\r
104 // for additional tests below.
\r
105 String newPersonAuthId = PersonAuthorityClientUtils.extractId(res);
\r
106 logger.info("Import: Created personAuthority: \"" + personAuthorityName +"\" ID:"
\r
107 +newPersonAuthId );
\r
109 // Add items to the personAuthority
\r
110 for(Map<String,String> personMap : personMaps){
\r
111 createItemInAuthority(newPersonAuthId, basePersonRefName, personMap);
\r
116 private String createItemInAuthority(String vcsid,
\r
117 String personAuthorityRefName, Map<String,String> personMap) {
\r
118 // Expected status code: 201 Created
\r
119 int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
\r
120 // Type of service request being tested
\r
121 ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
\r
122 String foreName = personMap.get(PersonJAXBSchema.FORE_NAME);
\r
123 String middleName = personMap.get(PersonJAXBSchema.MIDDLE_NAME);
\r
124 String surName = personMap.get(PersonJAXBSchema.SUR_NAME);
\r
125 String birthDate = personMap.get(PersonJAXBSchema.BIRTH_DATE);
\r
126 String deathDate = personMap.get(PersonJAXBSchema.DEATH_DATE);
\r
127 StringBuilder builtName = new StringBuilder();
\r
129 builtName.append(foreName);
\r
130 if(middleName!=null)
\r
131 builtName.append(middleName);
\r
133 builtName.append(surName);
\r
134 if(birthDate!=null)
\r
135 builtName.append(birthDate);
\r
136 builtName.append("-");
\r
137 if(deathDate!=null)
\r
138 builtName.append(deathDate);
\r
140 String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
\r
142 String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString(), displaySuffix); //TODO was ...,true);
\r
143 logger.info("Import: Create Item: \""+refName+"\" in personAuthority: \"" + personAuthorityRefName +"\"");
\r
145 if(logger.isDebugEnabled()){
\r
146 logger.debug("Import: Create Item: \""+builtName.toString()
\r
147 +"\" in personAuthorityulary: \"" + personAuthorityRefName +"\"");
\r
149 PoxPayloadOut multipart = createPersonInstance( vcsid, refName,
\r
151 ClientResponse<Response> res = client.createItem(vcsid, multipart);
\r
153 int statusCode = res.getStatus();
\r
155 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
156 throw new RuntimeException("Could not create Item: \""+refName
\r
157 +"\" in personAuthority: \"" + personAuthorityRefName
\r
158 +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
160 if(statusCode != EXPECTED_STATUS_CODE) {
\r
161 throw new RuntimeException("Unexpected Status when creating Item: \""+refName
\r
162 +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode);
\r
165 return PersonAuthorityClientUtils.extractId(res);
\r
169 // ---------------------------------------------------------------
\r
171 // ---------------------------------------------------------------
\r
173 private PersonauthoritiesCommonList readPersonAuthorities() {
\r
175 // Expected status code: 200 OK
\r
176 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
177 // Type of service request being tested
\r
178 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
180 // Submit the request to the service and store the response.
\r
181 ClientResponse<PersonauthoritiesCommonList> res = client.readList();
\r
182 PersonauthoritiesCommonList list = res.getEntity();
\r
184 int statusCode = res.getStatus();
\r
185 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
186 throw new RuntimeException("Could not read list of personAuthorities: "
\r
187 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
189 if(statusCode != EXPECTED_STATUS_CODE) {
\r
190 throw new RuntimeException("Unexpected Status when reading " +
\r
191 "list of personAuthorities, Status:"+ statusCode);
\r
197 private List<String> readPersonAuthorityIds(PersonauthoritiesCommonList list) {
\r
199 List<String> ids = new ArrayList<String>();
\r
200 List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
\r
201 list.getPersonauthorityListItem();
\r
202 for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
\r
203 ids.add(personAuthority.getCsid());
\r
208 private PersonauthoritiesCommon readPersonAuthority(String personAuthId) {
\r
210 // Expected status code: 200 OK
\r
211 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
212 // Type of service request being tested
\r
213 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
215 // Submit the request to the service and store the response.
\r
216 PersonauthoritiesCommon personAuthority = null;
\r
218 ClientResponse<String> res = client.read(personAuthId);
\r
219 int statusCode = res.getStatus();
\r
220 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
221 throw new RuntimeException("Could not read personAuthority"
\r
222 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
224 if(statusCode != EXPECTED_STATUS_CODE) {
\r
225 throw new RuntimeException("Unexpected Status when reading " +
\r
226 "personAuthority, Status:"+ statusCode);
\r
228 PoxPayloadIn input = (PoxPayloadIn) res.getEntity();
\r
229 personAuthority = (PersonauthoritiesCommon) extractPart(input,
\r
230 client.getCommonPartName(), PersonauthoritiesCommon.class);
\r
231 } catch (Exception e) {
\r
232 throw new RuntimeException("Could not read personAuthority: ", e);
\r
235 return personAuthority;
\r
238 private PersonsCommonList readItemsInPersonAuth(String personAuthId) {
\r
240 // Expected status code: 200 OK
\r
241 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
242 // Type of service request being tested
\r
243 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
245 // Submit the request to the service and store the response.
\r
246 ClientResponse<PersonsCommonList> res = client.readItemList(personAuthId, "", ""); //TODO: Laramie201007289 added empty strings to satisfy api
\r
247 PersonsCommonList list = res.getEntity();
\r
249 int statusCode = res.getStatus();
\r
251 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
252 throw new RuntimeException("Could not read items in personAuthority: "
\r
253 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
255 if(statusCode != EXPECTED_STATUS_CODE) {
\r
256 throw new RuntimeException("Unexpected Status when reading " +
\r
257 "items in personAuthority, Status:"+ statusCode);
\r
263 private List<String> readPersonIds(PersonsCommonList list) {
\r
265 List<String> ids = new ArrayList<String>();
\r
266 List<PersonsCommonList.PersonListItem> items =
\r
267 list.getPersonListItem();
\r
268 for (PersonsCommonList.PersonListItem item : items) {
\r
269 ids.add(item.getCsid());
\r
274 // ---------------------------------------------------------------
\r
276 // ---------------------------------------------------------------
\r
278 private void deletePersonAuthority(String vcsid) {
\r
279 // Expected status code: 200 OK
\r
280 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
281 // Type of service request being tested
\r
282 ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
\r
284 ClientResponse<Response> res = client.delete(vcsid);
\r
285 int statusCode = res.getStatus();
\r
287 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
288 throw new RuntimeException("Could not delete personAuthority: "
\r
289 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
291 if(statusCode != EXPECTED_STATUS_CODE) {
\r
292 throw new RuntimeException("Unexpected Status when deleting " +
\r
293 "personAuthority, Status:"+ statusCode);
\r
297 private void deleteAllPersonAuthorities() {
\r
298 List<String> ids = readPersonAuthorityIds(readPersonAuthorities());
\r
299 for (String id : ids) {
\r
300 deletePersonAuthority(id);
\r
304 private void deletePerson(String vcsid, String itemcsid) {
\r
305 // Expected status code: 200 OK
\r
306 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
307 // Type of service request being tested
\r
308 ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
\r
310 ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);
\r
311 int statusCode = res.getStatus();
\r
313 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
314 throw new RuntimeException("Could not delete personAuthority item: "
\r
315 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
317 if(statusCode != EXPECTED_STATUS_CODE) {
\r
318 throw new RuntimeException("Unexpected Status when deleting " +
\r
319 "personAuthority item, Status:"+ statusCode);
\r
323 private void deleteAllItemsForPersonAuth(String personAuthId) {
\r
324 List<String> itemIds = readPersonIds(readItemsInPersonAuth(personAuthId));
\r
325 for (String itemId : itemIds) {
\r
326 deletePerson(personAuthId, itemId);
\r
330 // ---------------------------------------------------------------
\r
331 // Utility methods used by tests above
\r
332 // ---------------------------------------------------------------
\r
335 private PoxPayloadOut createPersonAuthorityInstance(
\r
336 String displayName, String refName ) {
\r
337 PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon();
\r
338 personAuthority.setDisplayName(displayName);
\r
339 personAuthority.setRefName(refName);
\r
340 personAuthority.setVocabType("PersonAuthority");
\r
341 PoxPayloadOut multipart = new PoxPayloadOut();
\r
342 OutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
\r
343 commonPart.getHeaders().add("label", client.getCommonPartName());
\r
345 if(logger.isDebugEnabled()){
\r
346 logger.debug("to be created, personAuthority common ",
\r
347 personAuthority, PersonauthoritiesCommon.class);
\r
354 private PoxPayloadOut createPersonInstance(String inAuthority,
\r
355 String refName, Map<String, String> personInfo ) {
\r
356 PersonsCommon person = new PersonsCommon();
\r
357 person.setInAuthority(inAuthority);
\r
358 person.setRefName(refName);
\r
359 String value = null;
\r
360 if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null)
\r
361 person.setForeName(value);
\r
362 if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null)
\r
363 person.setMiddleName(value);
\r
364 if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null)
\r
365 person.setSurName(value);
\r
366 if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null)
\r
367 person.setInitials(value);
\r
368 if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null)
\r
369 person.setSalutation(value);
\r
370 if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null)
\r
371 person.setTitle(value);
\r
372 if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null)
\r
373 person.setNameAdditions(value);
\r
374 if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null)
\r
375 person.setBirthDate(value);
\r
376 if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null)
\r
377 person.setDeathDate(value);
\r
378 if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_PLACE))!=null)
\r
379 person.setBirthPlace(value);
\r
380 if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null)
\r
381 person.setDeathPlace(value);
\r
383 /* TODO: Laramie20100728 removed missing member calls
\r
384 if((value = (String)personInfo.get(PersonJAXBSchema.GROUP))!=null)
\r
385 person.setGroup(value);
\r
386 if((value = (String)personInfo.get(PersonJAXBSchema.NATIONALITY))!=null)
\r
387 person.setNationality(value);
\r
388 if((value = (String)personInfo.get(PersonJAXBSchema.OCCUPATION))!=null)
\r
389 person.setOccupation(value);
\r
390 if((value = (String)personInfo.get(PersonJAXBSchema.SCHOOL_OR_STYLE))!=null)
\r
391 person.setSchoolOrStyle(value);
\r
394 if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null)
\r
395 person.setGender(value);
\r
396 if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)
\r
397 person.setBioNote(value);
\r
398 if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)
\r
399 person.setNameNote(value);
\r
400 PoxPayloadOut multipart = new PoxPayloadOut();
\r
401 OutputPart commonPart = multipart.addPart(person,
\r
402 MediaType.APPLICATION_XML_TYPE);
\r
403 commonPart.getHeaders().add("label", client.getItemCommonPartName());
\r
405 if(logger.isDebugEnabled()){
\r
406 logger.debug("to be created, person common"+person);
\r
412 // Retrieve individual fields of personAuthority records.
\r
414 private String displayAllPersonAuthorities(PersonauthoritiesCommonList list) {
\r
415 StringBuffer sb = new StringBuffer();
\r
416 List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
\r
417 list.getPersonauthorityListItem();
\r
419 for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
\r
420 sb.append("personAuthority [" + i + "]" + "\n");
\r
421 sb.append(displayPersonAuthorityDetails(personAuthority));
\r
424 return sb.toString();
\r
427 private String displayPersonAuthorityDetails(
\r
428 PersonauthoritiesCommonList.PersonauthorityListItem personAuthority) {
\r
429 StringBuffer sb = new StringBuffer();
\r
430 sb.append("displayName=" + personAuthority.getDisplayName() + "\n");
\r
431 sb.append("vocabType=" + personAuthority.getVocabType() + "\n");
\r
432 // sb.append("csid=" + personAuthority.getCsid() + "\n");
\r
433 sb.append("URI=" + personAuthority.getUri() + "\n");
\r
434 return sb.toString();
\r
437 // Retrieve individual fields of person records.
\r
439 private String displayAllPersons(PersonsCommonList list) {
\r
440 StringBuffer sb = new StringBuffer();
\r
441 List<PersonsCommonList.PersonListItem> items =
\r
442 list.getPersonListItem();
\r
444 for (PersonsCommonList.PersonListItem item : items) {
\r
445 sb.append("person [" + i + "]" + "\n");
\r
446 sb.append(displayPersonDetails(item));
\r
449 return sb.toString();
\r
452 private String displayPersonDetails(
\r
453 PersonsCommonList.PersonListItem item) {
\r
454 StringBuffer sb = new StringBuffer();
\r
455 sb.append("csid=" + item.getCsid() + "\n");
\r
456 sb.append("displayName=" + item.getDisplayName() + "\n");
\r
457 // sb.append("URI=" + item.getUri() + "\n");
\r
458 return sb.toString();
\r
461 private Object extractPart(PoxPayloadIn input, String label,
\r
462 Class clazz) throws Exception {
\r
464 for(InputPart part : input.getParts()){
\r
465 String partLabel = part.getHeaders().getFirst("label");
\r
466 if(label.equalsIgnoreCase(partLabel)){
\r
467 String partStr = part.getBodyAsString();
\r
468 if(logger.isDebugEnabled()){
\r
469 logger.debug("extracted part str=\n" + partStr);
\r
471 obj = part.getBody(clazz, null);
\r
472 if(logger.isDebugEnabled()){
\r
473 logger.debug("extracted part obj=\n", obj, clazz);
\r
481 public static void main(String[] args) {
\r
483 // Configure logging.
\r
484 BasicConfigurator.configure();
\r
486 logger.info("PersonAuthority Sample starting...");
\r
488 Sample sample = new Sample();
\r
489 PersonauthoritiesCommonList personAuthorities;
\r
490 List<String> personAuthIds;
\r
491 String details = "";
\r
493 // Optionally delete all personAuthorities and persons.
\r
495 boolean ENABLE_DELETE_ALL = false;
\r
496 if (ENABLE_DELETE_ALL) {
\r
498 logger.info("Deleting all persons and personAuthorities ...");
\r
500 // For each personAuthority ...
\r
501 personAuthorities = sample.readPersonAuthorities();
\r
502 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
503 for (String personAuthId : personAuthIds) {
\r
504 logger.info("Deleting all persons for personAuthority ...");
\r
505 sample.deleteAllItemsForPersonAuth(personAuthId);
\r
506 logger.info("Deleting personAuthority ...");
\r
507 sample.deletePersonAuthority(personAuthId);
\r
510 logger.info("Reading personAuthorities after deletion ...");
\r
511 personAuthorities = sample.readPersonAuthorities();
\r
512 details = sample.displayAllPersonAuthorities(personAuthorities);
\r
513 logger.info(details);
\r
515 logger.info("Reading items in each personAuthority after deletion ...");
\r
516 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
517 for (String personAuthId : personAuthIds) {
\r
518 PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
\r
519 details = sample.displayAllPersons(items);
\r
520 logger.info(details);
\r
525 // Create new authorities, each populated with persons.
\r
527 Map<String, String> johnWayneMap = new HashMap<String,String>();
\r
528 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, "John");
\r
529 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
\r
530 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
\r
531 Map<String, String> patrickSchmitzMap = new HashMap<String,String>();
\r
532 patrickSchmitzMap.put(PersonJAXBSchema.FORE_NAME, "Patrick");
\r
533 patrickSchmitzMap.put(PersonJAXBSchema.SUR_NAME, "Schmitz");
\r
534 patrickSchmitzMap.put(PersonJAXBSchema.GENDER, "male");
\r
535 Map<String, String> janeDoeMap = new HashMap<String,String>();
\r
536 janeDoeMap.put(PersonJAXBSchema.FORE_NAME, "Jane");
\r
537 janeDoeMap.put(PersonJAXBSchema.SUR_NAME, "Doe");
\r
538 janeDoeMap.put(PersonJAXBSchema.GENDER, "female");
\r
539 List<Map<String, String>> personsMaps =
\r
540 Arrays.asList(johnWayneMap, patrickSchmitzMap, janeDoeMap );
\r
542 sample.createPersonAuthority("Sample Person Auth", personsMaps);
\r
544 logger.info("PersonAuthority Sample complete.");
\r
546 logger.info("Reading personAuthorities and items ...");
\r
547 // Get a list of personAuthorities.
\r
548 personAuthorities = sample.readPersonAuthorities();
\r
549 // For each personAuthority ...
\r
550 for (PersonauthoritiesCommonList.PersonauthorityListItem
\r
551 personAuthority : personAuthorities.getPersonauthorityListItem()) {
\r
552 // Get its display name.
\r
553 logger.info(personAuthority.getDisplayName());
\r
554 // Get a list of the persons in this personAuthority.
\r
555 PersonsCommonList items =
\r
556 sample.readItemsInPersonAuth(personAuthority.getCsid());
\r
557 // For each person ...
\r
558 for (PersonsCommonList.PersonListItem
\r
559 item : items.getPersonListItem()) {
\r
560 // Get its short name.
\r
561 logger.info(" " + item.getDisplayName());
\r
565 // Sample alternate methods of reading all personAuthorities and
\r
566 // persons separately.
\r
567 boolean RUN_ADDITIONAL_SAMPLES = false;
\r
568 if (RUN_ADDITIONAL_SAMPLES) {
\r
570 logger.info("Reading all personAuthorities ...");
\r
571 details = sample.displayAllPersonAuthorities(personAuthorities);
\r
572 logger.info(details);
\r
574 logger.info("Reading all persons ...");
\r
575 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
576 for (String personAuthId : personAuthIds) {
\r
577 PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
\r
578 details = sample.displayAllPersons(items);
\r
579 logger.info(details);
\r