Author Archives: Raghavendar T S

Update Properties of Multiple Edges – Gremlin Query – Titan

Update Properties of Multiple Edges - Gremlin Query - Titan

Update Properties of Multiple Edges – Gremlin Query – Titan

Update Properties of Multiple Edges

e = g.V().hasLabel('TEST_LABEL').has('property1','value1').bothE();
e.property('property3','value3').property('property4','value4');

Related Links:

  1. Gremlin Query Language - Create Vertex/Node and Edge/Relationship
  2. Check If Vertex/Edge Exist - Gremlin Query - Titan
  3. Update Properties of Multiple Edges - Gremlin Query - Titan
  4. Update Properties of Multiple Vertices - Gremlin Query - Titan
  5. Create Vertex If Does Not Exist - Gremlin Query - Titan
  6. Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan
  7. Update Vertex If Exist - Gremlin Query - Titan
  8. Update Multiple Properties of Vertex - Gremlin Query - Titan
Read More...

Update Properties of Multiple Vertices – Gremlin Query – Titan

Update Properties of Multiple Vertices - Gremlin Query - Titan

Update Properties of Multiple Vertices – Gremlin Query – Titan

Update Properties of Multiple Vertices

v = g.V().hasLabel('TEST_LABEL').has('property1','value1').has('property2','value2');
v.property('property3','value3').property('property4','value4');

Related Links:

  1. Gremlin Query Language - Create Vertex/Node and Edge/Relationship
  2. Check If Vertex/Edge Exist - Gremlin Query - Titan
  3. Update Properties of Multiple Edges - Gremlin Query - Titan
  4. Update Properties of Multiple Vertices - Gremlin Query - Titan
  5. Create Vertex If Does Not Exist - Gremlin Query - Titan
  6. Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan
  7. Update Vertex If Exist - Gremlin Query - Titan
  8. Update Multiple Properties of Vertex - Gremlin Query - Titan
Read More...

Create Vertex If Does Not Exist – Gremlin Query – Titan

Create Vertex If Does Not Exist - Gremlin Query - Titan

Create Vertex If Does Not Exist – Gremlin Query – Titan

Create Vertex If Does Not Exist

Return a vertex with given label and property. If the vertex does not exist, a new vertex is created and returned to vertexObject.

vertexObject = g.V().hasLabel('VERTEX_LABEL').has('property','value').tryNext().orElseGet{
    graph.addVertex(label, 'VERTEX_LABEL', 'property', 'value');
};

Related Links:

  1. Gremlin Query Language - Create Vertex/Node and Edge/Relationship
  2. Check If Vertex/Edge Exist - Gremlin Query - Titan
  3. Update Properties of Multiple Edges - Gremlin Query - Titan
  4. Update Properties of Multiple Vertices - Gremlin Query - Titan
  5. Create Vertex If Does Not Exist - Gremlin Query - Titan
  6. Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan
  7. Update Vertex If Exist - Gremlin Query - Titan
  8. Update Multiple Properties of Vertex - Gremlin Query - Titan
Read More...

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query – Gremlin Query – Titan

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan

Query/Access Root Level Properties and Nested Properties of Vertex in Single Query – Gremlin Query – Titan

Gremlin Query:

g.V().hasLabel('TEST_LABEL').has('_id','xxxxxxxxxxxxxx').as('v')
.select('v').valueMap(true).as('properties')
.select('v').properties('nestedPropertiesKey').valueMap().as('nestedProperties')
.select('properties','nestedProperties')

Sample Response:

{
     "properties":{
          "attr1":"value1"
     },
     "nestedProperties":{
          "nestedAttr1":"nestedValue1"
     }

}

Related Links:

  1. Gremlin Query Language - Create Vertex/Node and Edge/Relationship
  2. Check If Vertex/Edge Exist - Gremlin Query - Titan
  3. Update Properties of Multiple Edges - Gremlin Query - Titan
  4. Update Properties of Multiple Vertices - Gremlin Query - Titan
  5. Create Vertex If Does Not Exist - Gremlin Query - Titan
  6. Query/Access Root Level Properties and Nested Properties of Vertex in Single Query - Gremlin Query - Titan
  7. Update Vertex If Exist - Gremlin Query - Titan
  8. Update Multiple Properties of Vertex - Gremlin Query - Titan
Read More...

Java – Break Filter Chain and Return Custom POJO Response from Servlet Filter

Java - Break Filter Chain and Return Custom POJO Response from Servlet Filter

Java – Break Filter Chain and Return Custom POJO Response from Servlet Filter

Sample Servlet Filter :

package com.application.test.security;

import com.application.test.response.ErrorResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class TestFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,ServletException {

        if(ANY CONDITION){
            //ANY POJO CLASS
            ErrorResponse errorResponse = new ErrorResponse();
            errorResponse.setCode(401);
            errorResponse.setMessage("Unauthorized Access");
   
            byte[] responseToSend = restResponseBytes(errorResponse);
            ((HttpServletResponse) response).setHeader("Content-Type", "application/json");
            ((HttpServletResponse) response).setStatus(401);
            response.getOutputStream().write(responseToSend);
            return;
        }

        //ANY OTHER BUSINESS LOGIC
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }

    private byte[] restResponseBytes(ErrorResponse eErrorResponse) throws IOException {
        String serialized = new ObjectMapper().writeValueAsString(eErrorResponse);
        return serialized.getBytes();
    }
}