package nl.idgis.publisher.service.json;

import com.fasterxml.jackson.databind.JsonNode;

import nl.idgis.publisher.domain.web.tree.DatasetLayer;
import nl.idgis.publisher.domain.web.tree.DatasetLayerRef;
import nl.idgis.publisher.domain.web.tree.StyleRef;

public class JsonDatasetLayerRef extends AbstractJsonLayerRef<DatasetLayer> implements DatasetLayerRef {
	
	public JsonDatasetLayerRef(JsonNode jsonNode) {
		super(jsonNode, AbstractJsonDatasetLayer.fromJson(jsonNode.get("layer")));
	}

	@Override
	public boolean isGroupRef() {
		return false;
	}
	
	@Override
	public DatasetLayerRef asDatasetRef() {		
		return this;
	}

	@Override
	public StyleRef getStyleRef() {
		return new JsonStyleRef(jsonNode.get("styleRef"));		
	}

}

@@ -703,16 +703,44 @@
 %09%09return
+ jsonNode.has (%22styleRef%22) ?
  new Jso
@@ -774,16 +774,23 @@
 leRef%22))
+ : null
 ;%09%09%0D%0A%09%7D%0D

Test for null values in JsonDatasetLayerRef