Adding UI extensibility
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / sync / entity / SearchableEntity.java
  *
  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
-package org.onap.aai.sparky.synchronizer.entity;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+package org.onap.aai.sparky.sync.entity;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import org.onap.aai.sparky.config.oxm.OxmModelLoader;
 import org.onap.aai.sparky.util.NodeUtils;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
 /**
  * The Class SearchableEntity.
  */
 public class SearchableEntity extends IndexableEntity implements IndexDocument {
-  protected List<String> searchTagCollection = new ArrayList<String>();
-
-  /**
-   * @return the mapper
-   */
-  public ObjectMapper getMapper() {
-    return mapper;
-  }
-
-  /**
-   * @param mapper the mapper to set
-   */
-  public void setMapper(ObjectMapper mapper) {
-    this.mapper = mapper;
-  }
-
-  /**
-   * @param searchTagCollection the searchTagCollection to set
-   */
-  public void setSearchTagCollection(List<String> searchTagCollection) {
-    this.searchTagCollection = searchTagCollection;
-  }
-
-  /**
-   * @param searchTagIdCollection the searchTagIdCollection to set
-   */
-  public void setSearchTagIdCollection(List<String> searchTagIdCollection) {
-    this.searchTagIdCollection = searchTagIdCollection;
-  }
 
-  /**
-   * @param searchTags the searchTags to set
-   */
-  public void setSearchTags(String searchTags) {
-    this.searchTags = searchTags;
-  }
-
-  /**
-   * @param searchTagIDs the searchTagIDs to set
-   */
-  public void setSearchTagIDs(String searchTagIDs) {
-    this.searchTagIDs = searchTagIDs;
-  }
+  @JsonIgnore
+  protected List<String> searchTagCollection = new ArrayList<String>();
 
+  @JsonIgnore
   protected List<String> searchTagIdCollection = new ArrayList<String>();
+
+  @JsonIgnore
   protected ObjectMapper mapper = new ObjectMapper();
 
   /**
@@ -89,19 +53,12 @@ public class SearchableEntity extends IndexableEntity implements IndexDocument {
     super();
   }
 
-  /**
-   * Instantiates a new searchable entity.
-   *
-   * @param loader the loader
-   */
-  public SearchableEntity(OxmModelLoader loader) {
-    super(loader);
-  }
-
   /*
    * Generated fields, leave the settings for junit overrides
    */
+
   protected String searchTags; // generated based on searchTagCollection values
+
   protected String searchTagIDs;
 
   /**
@@ -114,7 +71,7 @@ public class SearchableEntity extends IndexableEntity implements IndexDocument {
   /*
    * (non-Javadoc)
    * 
-   * @see org.onap.aai.sparky.synchronizer.entity.IndexDocument#deriveFields()
+   * @see org.openecomp.sparky.synchronizer.entity.IndexDocument#deriveFields()
    */
   @Override
   public void deriveFields() {
@@ -145,34 +102,25 @@ public class SearchableEntity extends IndexableEntity implements IndexDocument {
     return searchTagCollection;
   }
 
+  @JsonProperty("searchTags")
   public String getSearchTags() {
     return searchTags;
   }
 
+  @JsonProperty("searchTagIDs")
   public String getSearchTagIDs() {
     return searchTagIDs;
   }
 
+  @JsonIgnore
   public List<String> getSearchTagIdCollection() {
     return searchTagIdCollection;
   }
 
   @Override
-  public String getIndexDocumentJson() {
-    ObjectNode rootNode = mapper.createObjectNode();
-    rootNode.put("entityType", this.getEntityType());
-    rootNode.put("entityPrimaryKeyValue", this.getEntityPrimaryKeyValue());
-    rootNode.put("searchTagIDs", this.getSearchTagIDs());
-    rootNode.put("searchTags", this.getSearchTags());
-    rootNode.put("link", this.getLink());
-    rootNode.put("lastmodTimestamp", this.getEntityTimeStamp());
-    return rootNode.toString();
-  }
-
-  @Override
-  public ObjectNode getBulkImportEntity() {
-    // TODO Auto-generated method stub
-    return null;
+  @JsonIgnore
+  public String getAsJson() throws JsonProcessingException {
+    return NodeUtils.convertObjectToJson(this, false);
   }
 
   /*