package com.altamiracorp.lumify.web.routes.vertex;

import com.altamiracorp.lumify.core.model.ontology.PropertyName;
import com.altamiracorp.lumify.core.user.User;
import com.altamiracorp.lumify.core.model.graph.GraphRepository;
import com.altamiracorp.lumify.core.model.graph.GraphVertex;
import com.altamiracorp.lumify.web.BaseRequestHandler;
import com.altamiracorp.miniweb.HandlerChain;
import com.google.inject.Inject;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.List;

public class VertexMultiple extends BaseRequestHandler {
    private final GraphRepository graphRepository;

    @Inject
    public VertexMultiple(final GraphRepository repo) {
        graphRepository = repo;
    }

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception {
        String[] vertexIds = request.getParameterValues("vertexIds[]");
        User user = getUser(request);

        List<GraphVertex> graphVertices = graphRepository.findVertices(vertexIds, user);

        Iterator<GraphVertex> i = graphVertices.iterator();
        while (i.hasNext()) {
            GraphVertex vertex = i.next();
            if (vertex == null || !vertex.getProperty(PropertyName.TYPE.toString()).equals("entity")) {
                i.remove();
            }
        }

        respondWithJson(response, GraphVertex.toJson(graphVertices));
    }
}

@@ -1280,76 +1280,210 @@
 null
- %7C%7C !vertex.getProperty(PropertyName.TYPE.toString()).equals(%22entity
+) %7B%0A                i.remove();%0A%0A            %7D else %7B%0A                Object type = vertex.getProperty(PropertyName.TYPE.toString());%0A                if (!type.equals(%22entity%22) && !type.equals(%22artifact
 %22)) 
@@ -1492,32 +1492,36 @@
                 
+  
+  
 i.remove();%0A    
@@ -1512,24 +1512,42 @@
 i.remove();%0A
+                %7D%0A
             

Fix artifacts not remaining in workspace [#61406622]