package org.unipop.jdbc.controller.star;

import org.apache.tinkerpop.gremlin.structure.Property;
import org.unipop.structure.BaseVertex;
import org.unipop.structure.BaseVertexProperty;
import org.unipop.structure.UniGraph;

import java.util.Map;

import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.table;

public class SqlVertex extends BaseVertex<SqlTableController>{

    protected SqlVertex(Object id, String label, Map<String, Object> keyValues, SqlTableController controller, UniGraph graph) {
        super(id, label, keyValues, controller, graph);
    }

    @Override
    protected void innerAddProperty(BaseVertexProperty vertexProperty) {
        getController().getContext().update(table(label))
                .set(field(vertexProperty.key()), vertexProperty.value())
                .where(field("ID").eq(this.id()))
                .execute();
    }

    @Override
    protected void innerRemoveProperty(Property property) {
        //getController().getContext().update(table(label)).set(field(property.key()));
    }

    @Override
    protected void innerRemove() {

    }
}

@@ -966,10 +966,33 @@
     
-//
+Object n = null;%0A        
 getC
@@ -1062,16 +1062,29 @@
 y.key())
+, n).execute(
 );%0A    %7D
@@ -1134,16 +1134,120 @@
 ove() %7B%0A
+        getController().getContext().delete(table(label)).where(field(%22ID%22).equal(this.id())).execute();
 %0A    %7D%0A%7D

implement remove & removeProperty