package jp.ac.u_tokyo.k.is;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.codehaus.jackson.JsonNode;

public class Link extends DataObject{
    public int angle;
    public JsonNode size;
    public JsonNode attrs;
    public String id;
    public String type;
    public JsonNode source;
    public JsonNode target;
    public int z;

    private String linkURI = SF.NS+"link#";
    private String nodeURI = SF.NS+"node#";
    
    public String toString(){
        return "angle:"+angle+" source:"+source.toString()+" id:"+id+" type:"+type+" z:"+z;
    }


    public HashMap<String,String> getFields(){
        HashMap<String,String> map = new HashMap<String,String>();
        map.put("angle",String.valueOf(angle));
        map.put("id",id);
        map.put("type","Link");
        map.put("typeClass","Link");
        map.put("shape",type);
        map.put("z",String.valueOf(z));
        map.put("source",nodeURI+source.get("id").asText());
        map.put("target",nodeURI+target.get("id").asText());
        map.put("stroke",attrs.get(".connection").get("stroke").asText());
        map.put("stroke_width",attrs.get(".connection").get("stroke-width").asText());
        map.put("d",attrs.get(".marker-target").get("d").asText());
        map.put("fill",attrs.get(".marker-target").get("fill").asText());
        super.targetURI = linkURI+id;
        List<String> rePredicates = new ArrayList<String>();
        rePredicates.add("source");
        rePredicates.add("target");
        super.setRePredicates(rePredicates);
        return map;

    }

}

@@ -702,32 +702,290 @@
 ring,String%3E();%0A
+        if(source.has(%22id%22) != false && target.has(%22id%22) != false)%7B %0A            map.put(%22source%22,nodeURI+source.get(%22id%22).asText());%0A            map.put(%22target%22,nodeURI+target.get(%22id%22).asText());%0A        %7D%0A        else%7B %0A            return map;%0A        %7D%0A
         map.put(
@@ -1186,130 +1186,8 @@
 ));%0A
-        map.put(%22source%22,nodeURI+source.get(%22id%22).asText());%0A        map.put(%22target%22,nodeURI+target.get(%22id%22).asText());%0A
     

modify not to add link witout resource/target