Skip to content

Commit a87bd08

Browse files
committed
[KNOWAGE-9298] Refactor eraseLayer method to use layer label instead of ID
1 parent 129af4f commit a87bd08

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

knowage-core/src/main/java/it/eng/spagobi/mapcatalogue/service/LayerCRUD.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,15 @@ public String postItem(@Context HttpServletRequest req) throws EMFUserError, JSO
332332
@Produces(MediaType.APPLICATION_JSON + "; charset=UTF-8")
333333
@UserConstraint(functionalities = { CommunityFunctionalityConstants.GEO_LAYERS_MANAGEMENT })
334334
public String deleteLayer(@Context HttpServletRequest req) throws JSONException {
335-
Object id = null;
336-
Integer layerId = null;
335+
Object label = null;
336+
String layerLabel = null;
337337

338338
try {
339-
id = req.getParameter("id");
340-
if (id == null || id.equals("")) {
339+
label = req.getParameter("label");
340+
if (label == null || label.equals("")) {
341341
throw new SpagoBIRuntimeException("The layer id passed in the request is null or empty");
342342
}
343-
layerId = new Integer(id.toString());
343+
layerLabel = label.toString();
344344
} catch (Exception e) {
345345
logger.error("error loading the layer to delete from the request", e);
346346
throw new SpagoBIRuntimeException("error loading the layer to delete from the request", e);
@@ -349,10 +349,10 @@ public String deleteLayer(@Context HttpServletRequest req) throws JSONException
349349
logger.debug("Deleting the layer");
350350
ISbiGeoLayersDAO dao = DAOFactory.getSbiGeoLayerDao();
351351
try {
352-
dao.eraseLayer(layerId);
352+
dao.eraseLayer(layerLabel);
353353
} catch (EMFUserError e) {
354-
logger.error("Error delationg the ayer with id " + id, e);
355-
throw new SpagoBIRuntimeException("Error delationg the layer with id " + id, e);
354+
logger.error("Error delationg the ayer with id " + label, e);
355+
throw new SpagoBIRuntimeException("Error delationg the layer with id " + label, e);
356356
}
357357
return "{}";
358358
}

knowagedao/src/main/java/it/eng/spagobi/mapcatalogue/dao/ISbiGeoLayersDAO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public interface ISbiGeoLayersDAO extends ISpagoBIDao {
4949

5050
public ArrayList<String> getProperties(String layerLabel);
5151

52-
public void eraseLayer(Integer layerId) throws EMFUserError, JSONException;
52+
public void eraseLayer(String layerLabel) throws EMFUserError, JSONException;
5353

5454
public void eraseRole(Integer roleId, Integer layerId) throws EMFUserError;
5555

knowagedao/src/main/java/it/eng/spagobi/mapcatalogue/dao/SbiGeoLayersDAOHibImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,15 +594,15 @@ private URL getURL(GeoLayer aLayer) throws Exception {
594594
*/
595595

596596
@Override
597-
public void eraseLayer(Integer layerId) throws EMFUserError, JSONException {
597+
public void eraseLayer(String label) throws EMFUserError, JSONException {
598598

599599
Session tmpSession = null;
600600
Transaction tx = null;
601601
try {
602602
tmpSession = getSession();
603603
tx = tmpSession.beginTransaction();
604604

605-
GeoLayer aLayer = loadLayerByID(layerId);
605+
GeoLayer aLayer = loadLayerByLabel(label);
606606
SbiGeoLayers hibLayer = new SbiGeoLayers(aLayer.getLayerId());
607607
hibLayer.setLabel(aLayer.getLabel());
608608
hibLayer.setName(aLayer.getName());

0 commit comments

Comments
 (0)