* VocabularyServiceTest, carries out tests against a\r
* deployed and running Vocabulary Service.\r
*\r
- * $LastChangedRevision: 753 $\r
- * $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $\r
+ * $LastChangedRevision$\r
+ * $LastChangedDate$\r
*/\r
public class Sample {\r
private static final Logger logger =\r
}\r
\r
public static void main(String[] args) {\r
- \r
+\r
+ // Configure logging.\r
BasicConfigurator.configure();\r
- logger.info("VocabularyBaseImport starting...");\r
\r
- Sample vbi = new Sample();\r
+ logger.info("VocabularyBaseImport starting...");\r
\r
- logger.info("Deleting all vocabulary items and vocabularies ...");\r
+ Sample vbi = new Sample();\r
+ VocabulariesCommonList vocabularies;\r
+ List<String> vocabIds;\r
+ String details = "";\r
\r
- // For each vocabulary ...\r
+ // Optionally delete all vocabularies and vocabulary items.\r
\r
- VocabulariesCommonList vocabularies = vbi.readVocabularies();\r
- List<String> vocabIds = vbi.readVocabularyIds(vocabularies);\r
- for (String vocabId : vocabIds) {\r
- // Delete vocabulary items for this vocabulary.\r
- logger.info("Deleting vocabulary items ...");\r
- vbi.deleteAllItemsForVocab(vocabId);\r
- // Delete vocabularies.\r
- logger.info("Deleting vocabulary ...");\r
- vbi.deleteVocabulary(vocabId);\r
- }\r
+ boolean ENABLE_DELETE_ALL = false;\r
+ if (ENABLE_DELETE_ALL) {\r
\r
- // Read vocabularies after deletion.\r
- logger.info("Reading vocabularies after deletion ...");\r
+ logger.info("Deleting all vocabulary items and vocabularies ...");\r
\r
- String details = "";\r
+ // For each vocabulary ...\r
+ vocabularies = vbi.readVocabularies();\r
+ vocabIds = vbi.readVocabularyIds(vocabularies);\r
+ for (String vocabId : vocabIds) {\r
+ logger.info("Deleting all vocabulary items for vocabulary ...");\r
+ vbi.deleteAllItemsForVocab(vocabId);\r
+ logger.info("Deleting vocabulary ...");\r
+ vbi.deleteVocabulary(vocabId);\r
+ }\r
\r
- vocabularies = vbi.readVocabularies();\r
- details = vbi.displayAllVocabularies(vocabularies);\r
- logger.info(details);\r
+ logger.info("Reading vocabularies after deletion ...");\r
+ vocabularies = vbi.readVocabularies();\r
+ details = vbi.displayAllVocabularies(vocabularies);\r
+ logger.info(details);\r
\r
- logger.info("Reading items in each vocabulary after deletion ...");\r
+ logger.info("Reading items in each vocabulary after deletion ...");\r
+ vocabIds = vbi.readVocabularyIds(vocabularies);\r
+ for (String vocabId : vocabIds) {\r
+ VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);\r
+ details = vbi.displayAllVocabularyItems(items);\r
+ logger.info(details);\r
+ }\r
\r
- // Read items in each vocabulary.\r
- vocabIds = vbi.readVocabularyIds(vocabularies);\r
- for (String vocabId : vocabIds) {\r
- VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);\r
- details = vbi.displayAllVocabularyItems(items);\r
- logger.info(details);\r
}\r
\r
-\r
// Create new vocabularies, each populated with vocabulary items.\r
\r
final String acquisitionMethodsVocabName = "Acquisition Methods";\r
"Ethnography","Herpetology","Media and Performance Art",\r
"Paintings and Sculpture","Paleobotany","Photographs",\r
"Prints and Drawings");\r
-\r
+ \r
vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);\r
vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);\r
vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);\r
\r
logger.info("VocabularyBaseImport complete.");\r
\r
- logger.info("Reading newly-created vocabularies ...");\r
-\r
- // Read vocabularies after import.\r
+ logger.info("Reading vocabularies and items ...");\r
+ // Get a list of vocabularies.\r
vocabularies = vbi.readVocabularies();\r
- details = vbi.displayAllVocabularies(vocabularies);\r
- logger.info(details);\r
+ // For each vocabulary ...\r
+ for (VocabulariesCommonList.VocabularyListItem\r
+ vocabulary : vocabularies.getVocabularyListItem()) {\r
+ // Get its display name.\r
+ logger.info(vocabulary.getDisplayName());\r
+ // Get a list of the vocabulary items in this vocabulary.\r
+ VocabularyitemsCommonList items =\r
+ vbi.readItemsInVocab(vocabulary.getCsid());\r
+ // For each vocabulary item ...\r
+ for (VocabularyitemsCommonList.VocabularyitemListItem\r
+ item : items.getVocabularyitemListItem()) {\r
+ // Get its display name.\r
+ logger.info(" " + item.getDisplayName());\r
+ }\r
+ }\r
\r
- logger.info("Reading items in each vocabulary ...");\r
+ // Sample alternate methods of reading all vocabularies and\r
+ // vocabulary items separately.\r
+ boolean RUN_ADDITIONAL_SAMPLES = false;\r
+ if (RUN_ADDITIONAL_SAMPLES) {\r
\r
- // Read items in each vocabulary after import.\r
- vocabIds = vbi.readVocabularyIds(vocabularies);\r
- for (String vocabId : vocabIds) {\r
- VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);\r
- details = vbi.displayAllVocabularyItems(items);\r
+ logger.info("Reading all vocabularies ...");\r
+ details = vbi.displayAllVocabularies(vocabularies);\r
logger.info(details);\r
+\r
+ logger.info("Reading all vocabulary items ...");\r
+ vocabIds = vbi.readVocabularyIds(vocabularies);\r
+ for (String vocabId : vocabIds) {\r
+ VocabularyitemsCommonList items = vbi.readItemsInVocab(vocabId);\r
+ details = vbi.displayAllVocabularyItems(items);\r
+ logger.info(details);\r
+ }\r
+\r
}\r
- \r
\r
}\r
\r