/*
|
* To change this license header, choose License Headers in Project Properties.
|
* To change this template file, choose Tools | Templates
|
* and open the template in the editor.
|
*/
|
package art.servers.transactionsserver.model.gis;
|
|
import art.library.model.transactions.gis.GeoLine;
|
import art.library.interop.InteropParameters;
|
import art.library.interop.InteropResponse;
|
import art.library.interop.serialization.SerializationException;
|
import art.servers.transactionsserver.Shared;
|
import java.util.List;
|
|
public class ModelConfigurationGeoline
|
{
|
|
public ModelConfigurationGeoline() throws Exception
|
{
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "set" class: <code>createConfigurationGeoline</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "lGeoLine" class: <code>GeoLine[]</code>
|
* @return <code>InteropResponse</code>
|
* <code>Boolean</code>
|
* @throws SerializationException
|
*/
|
public InteropResponse createConfigurationGeoline(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
GeoLine[] lGeoLine = (GeoLine[]) parameters.getParameterValue("lGeoLine");
|
|
try
|
{
|
for (GeoLine geoLine : lGeoLine)
|
{
|
try
|
{
|
Shared.controllerDatabase.getTimelessPersistance().get(0).updateOrAddObject(geoLine);
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
}
|
return new InteropResponse(true);
|
} catch (Exception e)
|
{
|
e.printStackTrace();
|
}
|
return new InteropResponse(false);
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "set" class: <code>readConfigurationGeoline</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "id" class: <code>Integer</code>
|
* @return <code>InteropResponse</code>
|
* <code>GeoLine</code>
|
* @throws SerializationException
|
*/
|
@SuppressWarnings("unchecked")
|
public InteropResponse readConfigurationGeoline(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
int id = (int) parameters.getParameterValue("id");
|
GeoLine geoLine;
|
|
try
|
{
|
geoLine = (GeoLine) Shared.controllerDatabase.getTimelessPersistance().get(0).getObject(GeoLine.class.getName(), "id=" + id).get(0);
|
} catch (Exception e)
|
{
|
throw new SerializationException(e.getMessage());
|
}
|
return new InteropResponse(geoLine);
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "set" class: <code>updateConfigurationGeoline</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "lGeoLine" class: <code>GeoLine[]</code>
|
* @return <code>InteropResponse</code>
|
* <code>Boolean</code>
|
* @throws SerializationException
|
*/
|
public InteropResponse updateConfigurationGeoline(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
GeoLine[] lGeoLine = (GeoLine[]) parameters.getParameterValue("lGeoLine");
|
try
|
{
|
createConfigurationGeoline(parameters);
|
return new InteropResponse(true);
|
} catch (Exception e)
|
{
|
e.getMessage();
|
return new InteropResponse(false);
|
}
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "set" class: <code>deleteConfigurationGeoline</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "lId" class: <code>Integer[]</code>
|
* @return <code>InteropResponse</code>
|
* <code>Boolean</code>
|
* @throws SerializationException
|
*/
|
public InteropResponse deleteConfigurationGeoline(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
int[] lId = (int[]) parameters.getParameterValue("lId");
|
|
try
|
{
|
for (int id : lId)
|
{
|
try
|
{
|
Shared.controllerDatabase.getTimelessPersistance().get(0).deleteObject(GeoLine.class.getName(), "id=" + id);
|
} catch (Exception e)
|
{
|
System.err.println(":: No se ha podido realizar la petición.");
|
e.printStackTrace();
|
}
|
}
|
return new InteropResponse(true);
|
} catch (Exception e)
|
{
|
e.getMessage();
|
return new InteropResponse(false);
|
}
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "set" class: <code>existConfigurationGeoline</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "id" class: <code>Integer</code>
|
* @return <code>InteropResponse</code>
|
* <code>Boolean</code>
|
* @throws SerializationException
|
*/
|
public InteropResponse existConfigurationGeoline(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
int id = (int) parameters.getParameterValue("id");
|
|
try
|
{
|
return new InteropResponse(Shared.controllerDatabase.getTimelessPersistance().get(0).existObject(GeoLine.class.getName(), "id=" + id));
|
} catch (Exception e)
|
{
|
throw new SerializationException(e.getMessage());
|
}
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "get" class: <code>getLayerConfigurationByLayerAndZoom</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "geoline" class: <code>GeoLine</code>
|
* @return <code>InteropResponse</code>
|
* <code>GeoLine[]</code>
|
* @throws SerializationException
|
*/
|
@SuppressWarnings("unchecked")
|
public InteropResponse getLayerConfigurationByLayerAndZoom(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
GeoLine geoline = (GeoLine) parameters.getParameterValue("geoline");
|
List<GeoLine> lGeoLine;
|
|
try
|
{
|
String operation = "(layer = '" + geoline.getLayer() + "') AND (zoom = " + geoline.getZoom() + ") ORDER BY zoom, width DESC";
|
lGeoLine = ((List<GeoLine>) (List<?>) Shared.controllerDatabase.getTimelessPersistance().get(0).getObject(GeoLine.class.getName(), operation));
|
return new InteropResponse(lGeoLine.toArray(new GeoLine[lGeoLine.size()]));
|
} catch (Exception e)
|
{
|
throw new SerializationException(e.getMessage());
|
}
|
}
|
|
/**
|
* @param parameters <code>InteropParameters</code>
|
* <p>name: "get" class: <code>getLayerConfigurationByLayerName</code>
|
* <p>name: "language" class: <code>String</code>
|
* <p>name: "layerName" class: <code>String</code>
|
* @return <code>InteropResponse</code>
|
* <code>GeoLine[]</code>
|
* @throws SerializationException
|
*/
|
@SuppressWarnings("unchecked")
|
public InteropResponse getLayerConfigurationByLayerName(InteropParameters parameters) throws SerializationException
|
{
|
String language = (String) parameters.getParameterValue("language");
|
String layerName = (String) parameters.getParameterValue("layerName");
|
List<GeoLine> lGeoLine;
|
try
|
{
|
String operation = "(layer = '" + layerName + "') ORDER BY zoom, width DESC";
|
lGeoLine = ((List<GeoLine>) (List<?>) Shared.controllerDatabase.getTimelessPersistance().get(0).getObject(GeoLine.class.getName(), operation));
|
return new InteropResponse(lGeoLine.toArray(new GeoLine[(lGeoLine.size())]));
|
} catch (Exception e)
|
{
|
throw new SerializationException(e.getMessage());
|
}
|
}
|
|
}
|