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.PoxPayloadIn;
\r
41 import org.collectionspace.services.client.PoxPayloadOut;
\r
42 import org.collectionspace.services.client.test.ServiceRequestType;
\r
43 import org.collectionspace.services.person.PersonauthoritiesCommon;
\r
44 import org.collectionspace.services.person.PersonauthoritiesCommonList;
\r
45 import org.collectionspace.services.person.PersonsCommon;
\r
46 import org.collectionspace.services.person.PersonsCommonList;
\r
47 import org.jboss.resteasy.client.ClientResponse;
\r
48 import org.jboss.resteasy.plugins.providers.multipart.InputPart;
\r
49 import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
\r
50 import org.slf4j.Logger;
\r
51 import org.slf4j.LoggerFactory;
\r
54 * PersonAuthority Sample, carries out tests against a
\r
55 * deployed and running PersonAuthority Service.
\r
57 * $LastChangedRevision: 1055 $
\r
58 * $LastChangedDate: 2009-12-09 12:25:15 -0800 (Wed, 09 Dec 2009) $
\r
60 public class Sample {
\r
61 private static final Logger logger =
\r
62 LoggerFactory.getLogger(Sample.class);
\r
64 // Instance variables specific to this test.
\r
65 private PersonAuthorityClient client = new PersonAuthorityClient();
\r
66 final String SERVICE_PATH_COMPONENT = "persons";
\r
67 final String ITEM_SERVICE_PATH_COMPONENT = "items";
\r
70 // ---------------------------------------------------------------
\r
72 // ---------------------------------------------------------------
\r
74 public void createPersonAuthority(String personAuthorityName,
\r
75 List<Map<String, String>> personMaps ) {
\r
77 // Expected status code: 201 Created
\r
78 int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
\r
79 // Type of service request being tested
\r
80 ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
\r
82 logger.info("Import: Create personAuthority: \"" + personAuthorityName +"\"");
\r
85 String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
\r
86 String basePersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix);//TODO: Laramie20100728 temp fix was personAuthorityName, false
\r
87 String fullPersonRefName = PersonAuthorityClientUtils.createPersonAuthRefName(personAuthorityName, displaySuffix); //TODO: Laramie20100728 temp fix was personAuthorityName, true
\r
88 PoxPayloadOut multipart =
\r
89 PersonAuthorityClientUtils.createPersonAuthorityInstance(
\r
90 personAuthorityName, fullPersonRefName, client.getCommonPartName() );
\r
91 ClientResponse<Response> res = client.create(multipart);
\r
93 int statusCode = res.getStatus();
\r
95 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
96 throw new RuntimeException("Could not create enumeration: \""+personAuthorityName
\r
97 +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
99 if(statusCode != EXPECTED_STATUS_CODE) {
\r
100 throw new RuntimeException("Unexpected Status when creating enumeration: \""
\r
101 +personAuthorityName +"\", Status:"+ statusCode);
\r
104 // Store the ID returned from this create operation
\r
105 // for additional tests below.
\r
106 String newPersonAuthId = PersonAuthorityClientUtils.extractId(res);
\r
107 logger.info("Import: Created personAuthority: \"" + personAuthorityName +"\" ID:"
\r
108 +newPersonAuthId );
\r
110 // Add items to the personAuthority
\r
111 for(Map<String,String> personMap : personMaps){
\r
112 createItemInAuthority(newPersonAuthId, basePersonRefName, personMap);
\r
117 private String createItemInAuthority(String vcsid,
\r
118 String personAuthorityRefName, Map<String,String> personMap) {
\r
119 // Expected status code: 201 Created
\r
120 int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
\r
121 // Type of service request being tested
\r
122 ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
\r
123 String foreName = personMap.get(PersonJAXBSchema.FORE_NAME);
\r
124 String middleName = personMap.get(PersonJAXBSchema.MIDDLE_NAME);
\r
125 String surName = personMap.get(PersonJAXBSchema.SUR_NAME);
\r
126 String birthDate = personMap.get(PersonJAXBSchema.BIRTH_DATE);
\r
127 String deathDate = personMap.get(PersonJAXBSchema.DEATH_DATE);
\r
128 StringBuilder builtName = new StringBuilder();
\r
130 builtName.append(foreName);
\r
131 if(middleName!=null)
\r
132 builtName.append(middleName);
\r
134 builtName.append(surName);
\r
135 if(birthDate!=null)
\r
136 builtName.append(birthDate);
\r
137 builtName.append("-");
\r
138 if(deathDate!=null)
\r
139 builtName.append(deathDate);
\r
141 String displaySuffix = "displayName-" + System.currentTimeMillis(); //TODO: Laramie20100728 temp fix, made-up displaySuffix.
\r
143 String refName = PersonAuthorityClientUtils.createPersonRefName(personAuthorityRefName, builtName.toString(), displaySuffix); //TODO was ...,true);
\r
144 logger.info("Import: Create Item: \""+refName+"\" in personAuthority: \"" + personAuthorityRefName +"\"");
\r
146 if(logger.isDebugEnabled()){
\r
147 logger.debug("Import: Create Item: \""+builtName.toString()
\r
148 +"\" in personAuthorityulary: \"" + personAuthorityRefName +"\"");
\r
150 PoxPayloadOut multipart = createPersonInstance( vcsid, refName,
\r
152 ClientResponse<Response> res = client.createItem(vcsid, multipart);
\r
154 int statusCode = res.getStatus();
\r
156 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
157 throw new RuntimeException("Could not create Item: \""+refName
\r
158 +"\" in personAuthority: \"" + personAuthorityRefName
\r
159 +"\" "+ PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
161 if(statusCode != EXPECTED_STATUS_CODE) {
\r
162 throw new RuntimeException("Unexpected Status when creating Item: \""+refName
\r
163 +"\" in personAuthority: \"" + personAuthorityRefName +"\", Status:"+ statusCode);
\r
166 return PersonAuthorityClientUtils.extractId(res);
\r
170 // ---------------------------------------------------------------
\r
172 // ---------------------------------------------------------------
\r
174 private PersonauthoritiesCommonList readPersonAuthorities() {
\r
176 // Expected status code: 200 OK
\r
177 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
178 // Type of service request being tested
\r
179 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
181 // Submit the request to the service and store the response.
\r
182 ClientResponse<PersonauthoritiesCommonList> res = client.readList();
\r
183 PersonauthoritiesCommonList list = res.getEntity();
\r
185 int statusCode = res.getStatus();
\r
186 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
187 throw new RuntimeException("Could not read list of personAuthorities: "
\r
188 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
190 if(statusCode != EXPECTED_STATUS_CODE) {
\r
191 throw new RuntimeException("Unexpected Status when reading " +
\r
192 "list of personAuthorities, Status:"+ statusCode);
\r
198 private List<String> readPersonAuthorityIds(PersonauthoritiesCommonList list) {
\r
200 List<String> ids = new ArrayList<String>();
\r
201 List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
\r
202 list.getPersonauthorityListItem();
\r
203 for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
\r
204 ids.add(personAuthority.getCsid());
\r
209 private PersonauthoritiesCommon readPersonAuthority(String personAuthId) {
\r
211 // Expected status code: 200 OK
\r
212 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
213 // Type of service request being tested
\r
214 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
216 // Submit the request to the service and store the response.
\r
217 PersonauthoritiesCommon personAuthority = null;
\r
219 ClientResponse<String> res = client.read(personAuthId);
\r
220 int statusCode = res.getStatus();
\r
221 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
222 throw new RuntimeException("Could not read personAuthority"
\r
223 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
225 if(statusCode != EXPECTED_STATUS_CODE) {
\r
226 throw new RuntimeException("Unexpected Status when reading " +
\r
227 "personAuthority, Status:"+ statusCode);
\r
229 PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
\r
230 personAuthority = (PersonauthoritiesCommon) extractPart(input,
\r
231 client.getCommonPartName(), PersonauthoritiesCommon.class);
\r
232 } catch (Exception e) {
\r
233 throw new RuntimeException("Could not read personAuthority: ", e);
\r
236 return personAuthority;
\r
239 private PersonsCommonList readItemsInPersonAuth(String personAuthId) {
\r
241 // Expected status code: 200 OK
\r
242 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
243 // Type of service request being tested
\r
244 ServiceRequestType REQUEST_TYPE = ServiceRequestType.READ;
\r
246 // Submit the request to the service and store the response.
\r
247 ClientResponse<PersonsCommonList> res = client.readItemList(personAuthId, "", ""); //TODO: Laramie201007289 added empty strings to satisfy api
\r
248 PersonsCommonList list = res.getEntity();
\r
250 int statusCode = res.getStatus();
\r
252 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
253 throw new RuntimeException("Could not read items in personAuthority: "
\r
254 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
256 if(statusCode != EXPECTED_STATUS_CODE) {
\r
257 throw new RuntimeException("Unexpected Status when reading " +
\r
258 "items in personAuthority, Status:"+ statusCode);
\r
264 private List<String> readPersonIds(PersonsCommonList list) {
\r
266 List<String> ids = new ArrayList<String>();
\r
267 List<PersonsCommonList.PersonListItem> items =
\r
268 list.getPersonListItem();
\r
269 for (PersonsCommonList.PersonListItem item : items) {
\r
270 ids.add(item.getCsid());
\r
275 // ---------------------------------------------------------------
\r
277 // ---------------------------------------------------------------
\r
279 private void deletePersonAuthority(String vcsid) {
\r
280 // Expected status code: 200 OK
\r
281 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
282 // Type of service request being tested
\r
283 ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
\r
285 ClientResponse<Response> res = client.delete(vcsid);
\r
286 int statusCode = res.getStatus();
\r
288 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
289 throw new RuntimeException("Could not delete personAuthority: "
\r
290 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
292 if(statusCode != EXPECTED_STATUS_CODE) {
\r
293 throw new RuntimeException("Unexpected Status when deleting " +
\r
294 "personAuthority, Status:"+ statusCode);
\r
298 private void deleteAllPersonAuthorities() {
\r
299 List<String> ids = readPersonAuthorityIds(readPersonAuthorities());
\r
300 for (String id : ids) {
\r
301 deletePersonAuthority(id);
\r
305 private void deletePerson(String vcsid, String itemcsid) {
\r
306 // Expected status code: 200 OK
\r
307 int EXPECTED_STATUS_CODE = Response.Status.OK.getStatusCode();
\r
308 // Type of service request being tested
\r
309 ServiceRequestType REQUEST_TYPE = ServiceRequestType.DELETE;
\r
311 ClientResponse<Response> res = client.deleteItem(vcsid, itemcsid);
\r
312 int statusCode = res.getStatus();
\r
314 if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
\r
315 throw new RuntimeException("Could not delete personAuthority item: "
\r
316 + PersonAuthorityClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
\r
318 if(statusCode != EXPECTED_STATUS_CODE) {
\r
319 throw new RuntimeException("Unexpected Status when deleting " +
\r
320 "personAuthority item, Status:"+ statusCode);
\r
324 private void deleteAllItemsForPersonAuth(String personAuthId) {
\r
325 List<String> itemIds = readPersonIds(readItemsInPersonAuth(personAuthId));
\r
326 for (String itemId : itemIds) {
\r
327 deletePerson(personAuthId, itemId);
\r
331 // ---------------------------------------------------------------
\r
332 // Utility methods used by tests above
\r
333 // ---------------------------------------------------------------
\r
336 private PoxPayloadOut createPersonAuthorityInstance(
\r
337 String displayName, String refName ) {
\r
338 PersonauthoritiesCommon personAuthority = new PersonauthoritiesCommon();
\r
339 personAuthority.setDisplayName(displayName);
\r
340 personAuthority.setRefName(refName);
\r
341 personAuthority.setVocabType("PersonAuthority");
\r
342 PoxPayloadOut multipart = new PoxPayloadOut();
\r
343 OutputPart commonPart = multipart.addPart(personAuthority, MediaType.APPLICATION_XML_TYPE);
\r
344 commonPart.getHeaders().add("label", client.getCommonPartName());
\r
346 if(logger.isDebugEnabled()){
\r
347 logger.debug("to be created, personAuthority common ",
\r
348 personAuthority, PersonauthoritiesCommon.class);
\r
355 private PoxPayloadOut createPersonInstance(String inAuthority,
\r
356 String refName, Map<String, String> personInfo ) {
\r
357 PersonsCommon person = new PersonsCommon();
\r
358 person.setInAuthority(inAuthority);
\r
359 person.setRefName(refName);
\r
360 String value = null;
\r
361 if((value = (String)personInfo.get(PersonJAXBSchema.FORE_NAME))!=null)
\r
362 person.setForeName(value);
\r
363 if((value = (String)personInfo.get(PersonJAXBSchema.MIDDLE_NAME))!=null)
\r
364 person.setMiddleName(value);
\r
365 if((value = (String)personInfo.get(PersonJAXBSchema.SUR_NAME))!=null)
\r
366 person.setSurName(value);
\r
367 if((value = (String)personInfo.get(PersonJAXBSchema.INITIALS))!=null)
\r
368 person.setInitials(value);
\r
369 if((value = (String)personInfo.get(PersonJAXBSchema.SALUTATIONS))!=null)
\r
370 person.setSalutation(value);
\r
371 if((value = (String)personInfo.get(PersonJAXBSchema.TITLE))!=null)
\r
372 person.setTitle(value);
\r
373 if((value = (String)personInfo.get(PersonJAXBSchema.NAME_ADDITIONS))!=null)
\r
374 person.setNameAdditions(value);
\r
375 if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_DATE))!=null) {
\r
376 StructuredDateGroup birthDate = new StructuredDateGroup();
\r
377 birthDate.setDateDisplayDate(value);
\r
378 person.setBirthDateGroup(birthDate);
\r
380 if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_DATE))!=null) {
\r
381 StructuredDateGroup deathDate = new StructuredDateGroup();
\r
382 deathDate.setDateDisplayDate(value);
\r
383 person.setDeathDateGroup(deathDate);
\r
385 if((value = (String)personInfo.get(PersonJAXBSchema.BIRTH_PLACE))!=null)
\r
386 person.setBirthPlace(value);
\r
387 if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null)
\r
388 person.setDeathPlace(value);
\r
390 /* TODO: Laramie20100728 removed missing member calls
\r
391 if((value = (String)personInfo.get(PersonJAXBSchema.GROUP))!=null)
\r
392 person.setGroup(value);
\r
393 if((value = (String)personInfo.get(PersonJAXBSchema.NATIONALITY))!=null)
\r
394 person.setNationality(value);
\r
395 if((value = (String)personInfo.get(PersonJAXBSchema.OCCUPATION))!=null)
\r
396 person.setOccupation(value);
\r
397 if((value = (String)personInfo.get(PersonJAXBSchema.SCHOOL_OR_STYLE))!=null)
\r
398 person.setSchoolOrStyle(value);
\r
401 if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null)
\r
402 person.setGender(value);
\r
403 if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)
\r
404 person.setBioNote(value);
\r
405 if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)
\r
406 person.setNameNote(value);
\r
407 PoxPayloadOut multipart = new PoxPayloadOut();
\r
408 OutputPart commonPart = multipart.addPart(person,
\r
409 MediaType.APPLICATION_XML_TYPE);
\r
410 commonPart.getHeaders().add("label", client.getItemCommonPartName());
\r
412 if(logger.isDebugEnabled()){
\r
413 logger.debug("to be created, person common"+person);
\r
419 // Retrieve individual fields of personAuthority records.
\r
421 private String displayAllPersonAuthorities(PersonauthoritiesCommonList list) {
\r
422 StringBuffer sb = new StringBuffer();
\r
423 List<PersonauthoritiesCommonList.PersonauthorityListItem> personAuthorities =
\r
424 list.getPersonauthorityListItem();
\r
426 for (PersonauthoritiesCommonList.PersonauthorityListItem personAuthority : personAuthorities) {
\r
427 sb.append("personAuthority [" + i + "]" + "\n");
\r
428 sb.append(displayPersonAuthorityDetails(personAuthority));
\r
431 return sb.toString();
\r
434 private String displayPersonAuthorityDetails(
\r
435 PersonauthoritiesCommonList.PersonauthorityListItem personAuthority) {
\r
436 StringBuffer sb = new StringBuffer();
\r
437 sb.append("displayName=" + personAuthority.getDisplayName() + "\n");
\r
438 sb.append("vocabType=" + personAuthority.getVocabType() + "\n");
\r
439 // sb.append("csid=" + personAuthority.getCsid() + "\n");
\r
440 sb.append("URI=" + personAuthority.getUri() + "\n");
\r
441 return sb.toString();
\r
444 // Retrieve individual fields of person records.
\r
446 private String displayAllPersons(PersonsCommonList list) {
\r
447 StringBuffer sb = new StringBuffer();
\r
448 List<PersonsCommonList.PersonListItem> items =
\r
449 list.getPersonListItem();
\r
451 for (PersonsCommonList.PersonListItem item : items) {
\r
452 sb.append("person [" + i + "]" + "\n");
\r
453 sb.append(displayPersonDetails(item));
\r
456 return sb.toString();
\r
459 private String displayPersonDetails(
\r
460 PersonsCommonList.PersonListItem item) {
\r
461 StringBuffer sb = new StringBuffer();
\r
462 sb.append("csid=" + item.getCsid() + "\n");
\r
463 sb.append("displayName=" + item.getDisplayName() + "\n");
\r
464 // sb.append("URI=" + item.getUri() + "\n");
\r
465 return sb.toString();
\r
468 private Object extractPart(PoxPayloadIn input, String label,
\r
469 Class clazz) throws Exception {
\r
471 for(InputPart part : input.getParts()){
\r
472 String partLabel = part.getHeaders().getFirst("label");
\r
473 if(label.equalsIgnoreCase(partLabel)){
\r
474 String partStr = part.getBodyAsString();
\r
475 if(logger.isDebugEnabled()){
\r
476 logger.debug("extracted part str=\n" + partStr);
\r
478 obj = part.getBody(clazz, null);
\r
479 if(logger.isDebugEnabled()){
\r
480 logger.debug("extracted part obj=\n", obj, clazz);
\r
488 public static void main(String[] args) {
\r
490 // Configure logging.
\r
491 BasicConfigurator.configure();
\r
493 logger.info("PersonAuthority Sample starting...");
\r
495 Sample sample = new Sample();
\r
496 PersonauthoritiesCommonList personAuthorities;
\r
497 List<String> personAuthIds;
\r
498 String details = "";
\r
500 // Optionally delete all personAuthorities and persons.
\r
502 boolean ENABLE_DELETE_ALL = false;
\r
503 if (ENABLE_DELETE_ALL) {
\r
505 logger.info("Deleting all persons and personAuthorities ...");
\r
507 // For each personAuthority ...
\r
508 personAuthorities = sample.readPersonAuthorities();
\r
509 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
510 for (String personAuthId : personAuthIds) {
\r
511 logger.info("Deleting all persons for personAuthority ...");
\r
512 sample.deleteAllItemsForPersonAuth(personAuthId);
\r
513 logger.info("Deleting personAuthority ...");
\r
514 sample.deletePersonAuthority(personAuthId);
\r
517 logger.info("Reading personAuthorities after deletion ...");
\r
518 personAuthorities = sample.readPersonAuthorities();
\r
519 details = sample.displayAllPersonAuthorities(personAuthorities);
\r
520 logger.info(details);
\r
522 logger.info("Reading items in each personAuthority after deletion ...");
\r
523 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
524 for (String personAuthId : personAuthIds) {
\r
525 PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
\r
526 details = sample.displayAllPersons(items);
\r
527 logger.info(details);
\r
532 // Create new authorities, each populated with persons.
\r
534 Map<String, String> johnWayneMap = new HashMap<String,String>();
\r
535 johnWayneMap.put(PersonJAXBSchema.FORE_NAME, "John");
\r
536 johnWayneMap.put(PersonJAXBSchema.SUR_NAME, "Wayne");
\r
537 johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
\r
538 Map<String, String> patrickSchmitzMap = new HashMap<String,String>();
\r
539 patrickSchmitzMap.put(PersonJAXBSchema.FORE_NAME, "Patrick");
\r
540 patrickSchmitzMap.put(PersonJAXBSchema.SUR_NAME, "Schmitz");
\r
541 patrickSchmitzMap.put(PersonJAXBSchema.GENDER, "male");
\r
542 Map<String, String> janeDoeMap = new HashMap<String,String>();
\r
543 janeDoeMap.put(PersonJAXBSchema.FORE_NAME, "Jane");
\r
544 janeDoeMap.put(PersonJAXBSchema.SUR_NAME, "Doe");
\r
545 janeDoeMap.put(PersonJAXBSchema.GENDER, "female");
\r
546 List<Map<String, String>> personsMaps =
\r
547 Arrays.asList(johnWayneMap, patrickSchmitzMap, janeDoeMap );
\r
549 sample.createPersonAuthority("Sample Person Auth", personsMaps);
\r
551 logger.info("PersonAuthority Sample complete.");
\r
553 logger.info("Reading personAuthorities and items ...");
\r
554 // Get a list of personAuthorities.
\r
555 personAuthorities = sample.readPersonAuthorities();
\r
556 // For each personAuthority ...
\r
557 for (PersonauthoritiesCommonList.PersonauthorityListItem
\r
558 personAuthority : personAuthorities.getPersonauthorityListItem()) {
\r
559 // Get its display name.
\r
560 logger.info(personAuthority.getDisplayName());
\r
561 // Get a list of the persons in this personAuthority.
\r
562 PersonsCommonList items =
\r
563 sample.readItemsInPersonAuth(personAuthority.getCsid());
\r
564 // For each person ...
\r
565 for (PersonsCommonList.PersonListItem
\r
566 item : items.getPersonListItem()) {
\r
567 // Get its short name.
\r
568 logger.info(" " + item.getDisplayName());
\r
572 // Sample alternate methods of reading all personAuthorities and
\r
573 // persons separately.
\r
574 boolean RUN_ADDITIONAL_SAMPLES = false;
\r
575 if (RUN_ADDITIONAL_SAMPLES) {
\r
577 logger.info("Reading all personAuthorities ...");
\r
578 details = sample.displayAllPersonAuthorities(personAuthorities);
\r
579 logger.info(details);
\r
581 logger.info("Reading all persons ...");
\r
582 personAuthIds = sample.readPersonAuthorityIds(personAuthorities);
\r
583 for (String personAuthId : personAuthIds) {
\r
584 PersonsCommonList items = sample.readItemsInPersonAuth(personAuthId);
\r
585 details = sample.displayAllPersons(items);
\r
586 logger.info(details);
\r