logs/
debug-logs/
*/appconfig-local/
+/.metadata/
resources.trust-store=tomcat_keystore
resources.maxSelfLinkTraversalDepth=2
resources.domain=aai
-resources.delimitedShallowEntities=cloud-region,complex,vnf-image,image,flavor,availability-zone,tenant,network-profile,l-interface
\ No newline at end of file
+resources.delimitedShallowEntities=cloud-region,complex,vnf-image,image,flavor,availability-zone,tenant,network-profile,l-interface
"type": "string",
"analyzer": "ngram_analyzer"
},
- "crossEntityReferenceValues": {
+ "crossReferenceEntityValues": {
"type": "string",
"analyzer": "ngram_analyzer"
},
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
String message =
"Error extracting version number from response, aborting aggregation entity sync of "
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
String requestPayload =
searchServiceAdapter.buildBulkImportOperationRequest(schemaConfig.getIndexName(),
- ae.getId(),jsonPayload);
+ versionNumber, ae.getId(),jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetTxn.getEntityType());
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
LOG.error(AaiUiMsgs.ES_ABORT_CROSS_ENTITY_REF_SYNC, "version Number",
icer.getEntityPrimaryKeyValue(), exc.getLocalizedMessage());
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
if (versionNumber != null && jsonPayload != null) {
String requestPayload = searchServiceAdapter.buildBulkImportOperationRequest(getIndexName(),
- icer.getId(), jsonPayload);
+ icer.getId(), versionNumber, jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetResult.getEntityType());
esWorkOnHand.decrementAndGet();
if (error != null) {
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
+ LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
} else {
updateElasticSearchCounters(result);
processStoreDocumentResult(result, esGetResult, icer);
IndexableCrossEntityReference icer = new IndexableCrossEntityReference();
- icer.setEntityType(resultDescriptor.getEntityName());
-
- List<String> primaryKeyValues = new ArrayList<String>();
- String pkeyValue = null;
-
- for (String keyName : resultDescriptor.getPrimaryKeyAttributeNames()) {
- pkeyValue = NodeUtils.getNodeFieldAsText(entityNode, keyName);
- if (pkeyValue != null) {
- primaryKeyValues.add(pkeyValue);
- } else {
- LOG.warn(AaiUiMsgs.ES_PKEYVALUE_NULL, resultDescriptor.getEntityName());
- }
- }
-
- final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
- icer.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
-
return icer;
}
private static final String SUGGEST_QUERY = "suggest";
private static final String BULK_API = "bulk";
private static final String DOCUMENT_EDNPOINT = "documents";
- private static final String SEARH_SERVICE_BULK_TEMPLATE =
- "{\"create\":{\"metaData\":{\"url\":\"%s\"},\"document\":\"%s\"}}\n";
+ private static final String SEARCH_SERVICE_BULK_TEMPLATE =
+ "[{\"update\":{\"metaData\":{\"url\":\"%s\", \"etag\":\"%s\"},\"document\":%s}}]\n";
private static final String SEARH_SERVICE_SINGLE_ENTITY_TEMPLATE =
"{\"queries\":[{\"must\":{\"match\":{\"field\":\"_id\",\"value\":\"%s\"}}}]}\n";
return headers;
}
-public String buildBulkImportOperationRequest(String indexName, String id, String payload){
+public String buildBulkImportOperationRequest(String indexName, String id, String version, String payload){
StringBuilder requestPayload = new StringBuilder(128);
- String SearchTarget = buildSearchServiceDocUrl(indexName,id);
+ String SearchTarget = buildSearchServiceDocBulkPayloadUrl(indexName,id);
- requestPayload.append(String.format(SEARH_SERVICE_BULK_TEMPLATE,SearchTarget,payload));
+ requestPayload.append(String.format(SEARCH_SERVICE_BULK_TEMPLATE,SearchTarget,version, payload));
return requestPayload.toString();
}
}
public String buildSearchServiceDocUrl(String indexName,String api) {
-
+
return String.format("https://%s:%s/services/search-data-service/%s/search/indexes/%s/%s/%s",
endpointConfig.getEndpointIpAddress(), endpointConfig.getEndpointServerPort(),
serviceApiVersion, indexName,DOCUMENT_EDNPOINT, api);
}
+ public String buildSearchServiceDocBulkPayloadUrl(String indexName,String api) {
+
+ return String.format("/services/search-data-service/%s/search/indexes/%s/%s/%s",
+ serviceApiVersion, indexName,DOCUMENT_EDNPOINT, api);
+ }
public String buildSearchServiceCreateDocApi(String indexName){
package org.onap.aai.sparky.sync.entity;
import java.util.ArrayList;
+import java.util.Arrays;
import org.onap.aai.sparky.util.NodeUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
-
+import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
+import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* The Class IndexableCrossEntityReference.
*/
-
+@JsonInclude(Include.NON_NULL)
public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
protected String crossReferenceEntityValues;
private static final String VIUI_SEARCH_TEMPLATE =
"{ " + "\"results-start\": 0," + "\"results-size\": %d," + "\"queries\": [{" + "\"must\": {"
- + "\"match\": {" + "\"field\": \"entityType searchTags crossEntityReferenceValues\","
+ + "\"match\": {" + "\"field\": \"entityType searchTags crossReferenceEntityValues\","
+ "\"value\": \"%s\"," + "\"operator\": \"and\", "
+ "\"analyzer\": \"whitespace_analyzer\"" + "}" + "}" + "}]" + "}";
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
String message =
"Error extracting version number from response, aborting searchable entity sync of "
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
if (versionNumber != null && jsonPayload != null) {
String requestPayload = searchServiceAdapter.buildBulkImportOperationRequest(getIndexName(),
- se.getId(), jsonPayload);
+ se.getId(), versionNumber, jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetTxn.getEntityType());
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.config.oxm.CrossEntityReferenceLookup;
import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
+import org.onap.aai.sparky.config.oxm.CrossEntityReferenceDescriptor;
+import org.onap.aai.sparky.config.oxm.CrossEntityReference;
import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
import org.onap.aai.sparky.config.oxm.SearchableEntityLookup;
cerLookup = new CrossEntityReferenceLookup();
processors.add(cerLookup);
-
+
+ Map<String, CrossEntityReferenceDescriptor> crossReferenceEntityDescriptors =
+ new HashMap<String, CrossEntityReferenceDescriptor>();
+
+ CrossEntityReferenceDescriptor crossReferenceEntiDescriptor = new CrossEntityReferenceDescriptor();
+ CrossEntityReference crossEntityReference = new CrossEntityReference();
+ crossEntityReference.setTargetEntityType("service-instance");
+ List<String> refEntities = new ArrayList<String>();
+ refEntities.add("service-type");
+ crossEntityReference.setReferenceAttributes(refEntities);
+
+ List<String> crossEntityPkeyNames = new ArrayList<String>();
+ crossEntityPkeyNames.add("service-type");
+ crossReferenceEntiDescriptor.setPrimaryKeyAttributeNames(crossEntityPkeyNames);
+
+ crossReferenceEntiDescriptor.setCrossEntityReference(crossEntityReference);
+ crossReferenceEntiDescriptor.setEntityName("service-subscription");
+ crossReferenceEntityDescriptors.put("service-subscription", crossReferenceEntiDescriptor);
+ cerLookup.setCrossReferenceEntityDescriptors(crossReferenceEntityDescriptors);
+
searchableEntityLookup = new SearchableEntityLookup();
processors.add(searchableEntityLookup);
-
-
aaiRestEndPointConfig = new RestEndpointConfig();
aaiRestEndPointConfig.setNumRequestRetries(5);
searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost", "2.0"));
assertNotNull(searchServiceAdapter.buildSuggestServiceQueryUrl("searchentity-localhost"));
+ assertEquals(searchServiceAdapter.buildBulkImportOperationRequest("testIndex", "1", "4", "{\"payload\":\"value\"}"),
+ "[{\"update\":{\"metaData\":{\"url\":\"/services/search-data-service/2.0/search/indexes/testIndex/documents/1\", "
+ + "\"etag\":\"4\"},\"document\":{\"payload\":\"value\"}}}]\n");
}
System.out.println(icer.getAsJson());
}
+
}