package org.onap.aai.introspection;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import com.google.common.base.CaseFormat;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
-import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang3.ClassUtils;
import org.eclipse.persistence.exceptions.DynamicException;
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.workarounds.NamingExceptions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class Introspector implements Cloneable {
- private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(Introspector.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(Introspector.class);
protected String className;
protected String uriChain = "";
private Set<String> uniqueProperties = null;
private Set<String> indexedProperties = null;
private Set<String> allKeys = null;
+ private Set<String> dslStartNodeProperties = null;
protected CaseFormatStore caseFormatStore = null;
protected NodeIngestor nodeIngestor;
Class<?> clazz = this.getClass(name);
if (this.isListType(name) && result == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
result = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
Class<?> clazz = this.getClass(name);
if (this.isListType(name) && value == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
value = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
Class<?> clazz = this.getClass(name);
if (isListType && value == null) {
try {
- this.set(convertedName, clazz.newInstance());
+ this.set(convertedName, clazz.getDeclaredConstructor().newInstance());
value = this.get(convertedName);
- } catch (DynamicException | InstantiationException | IllegalAccessException e) {
+ } catch (DynamicException | InstantiationException | IllegalAccessException | IllegalArgumentException
+ | InvocationTargetException | NoSuchMethodException | SecurityException e) {
LOGGER.warn(e.getMessage(), e);
}
}
if (obj != null) {
try {
- if (!obj.getClass().getName().equals(nameClass.getName())) {
+ if (!(obj.getClass().getCanonicalName().equals(nameClass.getCanonicalName()))) {
if (nameClass.isPrimitive()) {
nameClass = ClassUtils.primitiveToWrapper(nameClass);
result = nameClass.getConstructor(String.class).newInstance(obj.toString());
public Set<String> getProperties(PropertyPredicate<Introspector, String> p) {
final Set<String> temp = new LinkedHashSet<>();
- this.getProperties().stream().filter(item -> {
- return p.test(this, item);
- }).forEach(item -> {
- temp.add(item);
- });
- final Set<String> result = Collections.unmodifiableSet(temp);
-
- return result;
-
+ this.getProperties().stream().filter(item -> p.test(this, item)).forEach(temp::add);
+ return Collections.unmodifiableSet(temp);
}
public Set<String> getSimpleProperties(PropertyPredicate<Introspector, String> p) {
return result;
}
+ public Set<String> getDslStartNodeProperties() {
+ Set<String> result = null;
+
+ if (this.dslStartNodeProperties == null) {
+ /*
+ * The dslStartNodeProperties will have keys by default
+ * If dslStartNodeProps exist in the oxm use it
+ * if not use the indexedProps
+ */
+ result = new LinkedHashSet<>(this.getKeys());
+
+ String dslKeys = this.getMetadata(ObjectMetadata.DSL_START_NODE_PROPS);
+ String indexedKeys = this.getMetadata(ObjectMetadata.INDEXED_PROPS);
+ if (dslKeys != null) {
+ Arrays.stream(dslKeys.split(",")).forEach(result::add);
+ } else if (indexedKeys != null) {
+ Arrays.stream(indexedKeys.split(",")).forEach(result::add);
+ }
+ this.dslStartNodeProperties = Collections.unmodifiableSet(result);
+ }
+ result = this.dslStartNodeProperties;
+ return result;
+ }
+
public Set<String> getUniqueProperties() {
Set<String> result = null;
if (this.uniqueProperties == null) {
/**
* This will returned the generic parameterized type of the underlying
* object if it exists
- *
+ *
* @param name
* @return the generic type of the java class of the underlying object
*/
/**
* Is this type not a Java String or primitive
- *
+ *
* @param name
* @return
*/