Connectors : Consolidation Server : Use Cases : UC-8: Consolidating Data from Storage Service
 
UC-8: Consolidating Data from Storage Service
 
Step 1 - Define the Source Connector for StorageService
Step 2 - Link storageService Tags to Countries
Step 3 - Add Tags to Countries
Step 4 - Index Tags
It is interesting to combine the information coming from Exalead CloudView features like tagging or comments, relying on the Storage Service, with original data to search or refine on new values.
In this use case, we want to index the tags defined on country documents (that is, storageKey_tags) and use them as new facets.
We assume that previous UCs have been completed.
The Storage Service is activated. For more information, see "Configuring Data Storage for Collaborative Widgets" in the Exalead CloudView Mashup Builder User's Guide.
The RepushFromCache setting must be set to false in the <DATADIR>/config/360/StorageService.xml file (default configuration).
Step 1 - Define the Source Connector for StorageService
1. In the Administration Console, go to Index > Connectors and click Add connector.
a. In Name, enter storageService.
b. For Type, select the JDBC connector.
c. For Push to PAPI server, select the Consolidation server cbx0 instance.
d. Click Accept.
2. For Store documents in data model class, enter storageValue.
Note: This class is not present in the data model yet. It is only used by the Consolidation Server.
3. In Connection parameters:
a. For Driver, enter org.sqlite.JDBC
b. For Connection string, enter jdbc:sqlite://<DATADIR>/storageService/storage.db.sqlite
c. Click Test connection. The database connector automatically connects to the database.
4. In Query parameters:
a. For Synchronization mode, select Query-based incremental synchronization
b. For Initial query, enter: select ikey, ukey, value, res_type, res_id, modified_date, source, app_id, build_group from cv360_storage_service
c. For All URI Query, enter: select ikey, ukey from cv360_storage_service
d. For Checkpoint query, enter: select max(modified_date) from cv360_storage_service
e. For Incremental variable, enter: TS
f. For Incremental query, enter: select ikey, ukey, value, res_type, res_id, modified_date, source, app_id, build_group from cv360_storage_service where modified_date > '$(TS)'
5. Click Retrieve fields.
6. Define the ukey and ikey fields as primary keys.
a. Click the ukey field to expand it.
b. Select Use as primary key.
c. Repeat the operation for the ikey field.
7. For the value field:
a. Delete the automatic processor.
b. Click Add column processor and add a MultipleMetas processor.
c. For Meta Name, enter value.
8. Click Apply.
Step 2 - Link storageService Tags to Countries
Configure the Transformation Processor
Important: For this Use Case step, we are going to use a Java processor delivered by default.
1. Go to Index > Consolidation
2. Add a new transformation processor:
a. Select Java as format.
b. For Name, enter StorageService.
c. For Processor, select Storage Service Key Linker Processor.
d. Click Accept.
3. For Source connector, select storageService
4. Click Save.
With this processor, we have achieved to link storageService tags to country documents.
Note: To get the same result with Groovy code, replace the default code by the following one:
// Process all nodes
process("") {
// Logs the content of the document passing through this processor
log.info "Received document: " + it

// Adding parent type
it.setType("storageValue", "storage");

// Create the virtual object depending on the name used for storing tag values
// URI = <key store name (tags[] for example)> + delimiter + link object key (res_id)
// Type: "storage_" + key store name without [] (tags[] for example)
keystoreObject = createDocument( 'storageKey_' + it.metas.getValue("ikey") + "-#-"
+ it.metas.getValue("res_id"), // keystore URI
"storageKey_" + it.metas.getValue("ikey")[0..-3], "storage" // type
);

// Add key name to the document (for debugging purpose only)
// remove last 2 characters:[]
keystoreObject.metas.name = it.metas.getValue("ikey")[0..-3]
yield keystoreObject;

// Add link from keystore value to keystore object
it.addArcFrom('hasForValue', 'storageKey_' + it.metas.getValue("ikey") + "-#-"
+ it.metas.getValue("res_id"));

// Add link from keystore object to linked object
keystoreObject.addArcFrom('hasStorageKey', it.metas.getValue("res_id"));

}
Configure the Aggregation Processors
Important: For this Use Case step, we are going to use Java processors delivered by default.
1. Add an aggregation processor:
a. Select Java as format.
b. For Name, enter Countries_UC_8.
c. For Processor, select Storage Service Key Flattener Processor.
d. Click Accept.
2. Configure the processor as follows:
a. For Processed Document type, enter country.
b. For Key store document type, enter storageKey_tags.
c. For Target meta, enter tags.
Note: To get the same result with Groovy code, replace the default code by the following one:
// Process nodes having the “country” type
process("country") {
// Add "tags[]" keystore values on countries
// by matching on nodes with the type [storageKey_tags]
// For other keys, use [storageKey_<whatever>]
for (node in (match(it, "hasStorageKey[storageKey_tags].hasForValue[storageValue]")*.last())) {
log.info "keystore value found : " + node.metas.getValues("value");
it.metas.tags.addAll(node.metas.getValues("value"))
}

log.info "country after tags : " + it
}
3. Add another aggregation processor to discard storage nodes:
a. Select Java as format.
b. For Name, enter Storage_UC_8.
c. For Processor, select Discard.
d. Click Accept.
4. For Discard document types, click Add item and enter storage.
Note: To get the same result with Groovy code, replace the default code by the following one:
process("storage") {
log.info "discard for : " + it
// discard storage nodes
discard()
}
5. Save and apply the configuration.
Step 3 - Add Tags to Countries
1. Open the following Mashup UI application page: http://<HOSTNAME>:<BASEPORT>/mashup-ui/page/searchcountry_v4
2. Search for a country, for example, Singapore .
3. Click the see details link.
4. Click the Tag this country link to add a tag to the selected country. For example, for Singapore, enter asian country and press ENTER.
asian country displays as tag.
5. Perform the 3 previous steps to tag Japan as asian country too.
Step 4 - Index Tags
1. Click Scan for the storageService JDBC connector and wait for data to be fully indexed.
Two documents are indexed for the storageService connector.
2. Open the Mashup UI application again: http://<HOSTNAME>:<BASEPORT>/mashup-ui/page/searchcountry_v4
You can now see a new Tags facet in the Refinements panel, displaying the values entered for the tagged documents.
The following graphic shows what we achieved on the object graph (Max. arcs per node has been set to 10 for more readability).