java/registry/src/main/java/io/opensaber/registry/service/impl/RegistryServiceImpl.java
/**
     * This method adds the entity into db, calls elastic and audit asynchronously
     *
     * @param rootNode - input value as string
     * @return
     * @throws Exception
     */
This method adds the entity into db, calls elastic and audit asynchronously
@param rootNode - input value as string
@return
@throws Exception
This method adds the entity into db calls elastic and audit asynchronously @param rootNode - input value as string @return @throws Exception
public String addEntity(Shard shard, String userId, JsonNode rootNode) throws Exception {
        Transaction tx = null;
        String entityId = "entityPlaceholderId";
        String vertexLabel = rootNode.fieldNames().next();
        systemFieldsHelper.ensureCreateAuditFields(vertexLabel, rootNode.get(vertexLabel), userId);
        if (encryptionEnabled) {
            rootNode = encryptionHelper.getEncryptedJson(rootNode);
        }
        if (signatureEnabled) {
            signatureHelper.signJson(rootNode);
        }
        if (persistenceEnabled) {
            DatabaseProvider dbProvider = shard.getDatabaseProvider();
            IRegistryDao registryDao = new RegistryDaoImpl(dbProvider, definitionsManager, uuidPropertyName);
            try (OSGraph osGraph = dbProvider.getOSGraph()) {
                Graph graph = osGraph.getGraphStore();
                tx = dbProvider.startTransaction(graph);
                entityId = registryDao.addEntity(graph, rootNode);
                if (commitEnabled) {
                    dbProvider.commitTransaction(graph, tx);
                }
            } finally {
                tx.close();
            }
            String shardId = shard.getShardId();
            Vertex parentVertex = entityParenter.getKnownParentVertex(vertexLabel, shardId);
            Definition definition = definitionsManager.getDefinition(vertexLabel);
            entityParenter.ensureIndexExists(dbProvider, parentVertex, definition, shardId);
            List<Integer> transactionId = new LinkedList<>(Arrays.asList(tx.hashCode()));
            List<String> entityTypes = new LinkedList<>(Arrays.asList(vertexLabel));
            if(auditEnabled) {
		        AuditRecord auditRecord = auditService.createAuditRecord(userId, Constants.AUDIT_ACTION_ADD, entityId, transactionId);
		        auditRecord.setAuditInfo(auditService.createAuditInfo(Constants.AUDIT_ACTION_ADD_OP, Constants.AUDIT_ACTION_ADD, null, rootNode, entityTypes));
            	auditService.doAudit(auditRecord, rootNode, entityTypes, entityId, shard);
            }
        }
        return entityId;
    }
public String addEntity ( Shard shard , String userId , JsonNode rootNode ) throws Exception { Transaction tx = null ; String entityId = "entityPlaceholderId" ; String vertexLabel = rootNode . fieldNames ( ) . next ( ) ; systemFieldsHelper . ensureCreateAuditFields ( vertexLabel , rootNode . get ( vertexLabel ) , userId ) ; if ( encryptionEnabled ) { rootNode = encryptionHelper . getEncryptedJson ( rootNode ) ; } if ( signatureEnabled ) { signatureHelper . signJson ( rootNode ) ; } if ( persistenceEnabled ) { DatabaseProvider dbProvider = shard . getDatabaseProvider ( ) ; IRegistryDao registryDao = new RegistryDaoImpl ( dbProvider , definitionsManager , uuidPropertyName ) ; try ( OSGraph osGraph = dbProvider . getOSGraph ( ) ) { Graph graph = osGraph . getGraphStore ( ) ; tx = dbProvider . startTransaction ( graph ) ; entityId = registryDao . addEntity ( graph , rootNode ) ; if ( commitEnabled ) { dbProvider . commitTransaction ( graph , tx ) ; } } finally { tx . close ( ) ; } String shardId = shard . getShardId ( ) ; Vertex parentVertex = entityParenter . getKnownParentVertex ( vertexLabel , shardId ) ; Definition definition = definitionsManager . getDefinition ( vertexLabel ) ; entityParenter . ensureIndexExists ( dbProvider , parentVertex , definition , shardId ) ; List < Integer > transactionId = new LinkedList < > ( Arrays . asList ( tx . hashCode ( ) ) ) ; List < String > entityTypes = new LinkedList < > ( Arrays . asList ( vertexLabel ) ) ; if ( auditEnabled ) { AuditRecord auditRecord = auditService . createAuditRecord ( userId , Constants . AUDIT_ACTION_ADD , entityId , transactionId ) ; auditRecord . setAuditInfo ( auditService . createAuditInfo ( Constants . AUDIT_ACTION_ADD_OP , Constants . AUDIT_ACTION_ADD , null , rootNode , entityTypes ) ) ; auditService . doAudit ( auditRecord , rootNode , entityTypes , entityId , shard ) ; } } return entityId ; }
This method adds the entity into db, calls elastic and audit asynchronously
 @param rootNode - input value as string
 @return
 @throws Exception
This method adds the entity into db calls elastic and audit asynchronously @param rootNode - input value as string @return @throws Exception
// Add indices: executes only once. //if Audit enabled in configuration yml file