Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.geojsf.mbean.admin.AbstractMapServiceBean Maven / Gradle / Ivy
package org.geojsf.mbean.admin;
import java.io.Serializable;
import java.util.List;
import org.geojsf.event.MapAjaxEvent;
import org.geojsf.factory.ejb.EjbGeoCategoryFactory;
import org.geojsf.factory.ejb.EjbGeoLayerFactory;
import org.geojsf.factory.ejb.EjbGeoMapFactory;
import org.geojsf.factory.ejb.EjbGeoServiceFactory;
import org.geojsf.factory.ejb.EjbGeoViewFactory;
import org.geojsf.factory.ejb.EjbGeoViewPortFactory;
import org.geojsf.interfaces.facade.GeoJsfFacade;
import org.geojsf.interfaces.model.core.GeoJsfCategory;
import org.geojsf.interfaces.model.core.GeoJsfLayer;
import org.geojsf.interfaces.model.core.GeoJsfMap;
import org.geojsf.interfaces.model.core.GeoJsfService;
import org.geojsf.interfaces.model.core.GeoJsfView;
import org.geojsf.interfaces.model.meta.GeoJsfDataSource;
import org.geojsf.interfaces.model.meta.GeoJsfViewPort;
import org.geojsf.interfaces.model.sld.GeoJsfSld;
import org.geojsf.interfaces.model.sld.GeoJsfSldRule;
import org.geojsf.interfaces.model.sld.GeoJsfSldTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.ahtutils.exception.ejb.UtilsConstraintViolationException;
import net.sf.ahtutils.exception.ejb.UtilsLockingException;
import net.sf.ahtutils.exception.ejb.UtilsNotFoundException;
import net.sf.ahtutils.factory.ejb.status.EjbDescriptionFactory;
import net.sf.ahtutils.factory.ejb.status.EjbLangFactory;
import net.sf.ahtutils.interfaces.model.graphic.UtilsGraphic;
import net.sf.ahtutils.interfaces.model.status.UtilsDescription;
import net.sf.ahtutils.interfaces.model.status.UtilsLang;
import net.sf.ahtutils.interfaces.model.status.UtilsStatus;
import net.sf.ahtutils.jsf.util.FacesContextMessage;
import net.sf.ahtutils.jsf.util.PositionListReorderer;
import net.sf.ahtutils.web.mbean.util.AbstractLogMessage;
public class AbstractMapServiceBean ,GT extends UtilsStatus,GS extends UtilsStatus,
CATEGORY extends GeoJsfCategory,
SERVICE extends GeoJsfService,
LAYER extends GeoJsfLayer,
MAP extends GeoJsfMap,
VIEW extends GeoJsfView,
VP extends GeoJsfViewPort,
DS extends GeoJsfDataSource,
SLDTEMPLATE extends GeoJsfSldTemplate,
SLDTYPE extends UtilsStatus,
SLD extends GeoJsfSld,
RULE extends GeoJsfSldRule>
implements Serializable
{
private static final long serialVersionUID = 1L;
final static Logger logger = LoggerFactory.getLogger(AbstractMapServiceBean.class);
private String[] langKeys;
private GeoJsfFacade fGeo;
protected EjbLangFactory efLang;
protected EjbDescriptionFactory efDescription;
protected EjbGeoCategoryFactory efCategory;
protected EjbGeoServiceFactory efService;
protected EjbGeoLayerFactory efLayer;
protected EjbGeoMapFactory efMap;
protected EjbGeoViewFactory efView;
protected EjbGeoViewPortFactory efViewPort;
private Class cCategory;
private Class cService;
private Class cLayer;
protected List services; public List getServices() {return services;}
protected List categories; public List getCategories() {return categories;}
protected List layers; public List getLayers() {return layers;}
protected List slds; public List getSlds() {return slds;}
protected MAP map; public MAP getMap() {return map;}
protected CATEGORY category; public CATEGORY getCategory(){return category;} public void setCategory(CATEGORY category){this.category = category;}
protected VP viewPort; public VP getViewPort(){return viewPort;} public void setViewPort(VP viewPort){this.viewPort = viewPort;}
protected SERVICE service; public SERVICE getService() {return service;} public void setService(SERVICE service) {this.service = service;}
protected LAYER layer; public LAYER getLayer() {return layer;} public void setLayer(LAYER layer) {this.layer = layer;}
public void initSuper(String[] langKeys, GeoJsfFacade fGeo, final Class cLang, final Class clDescription, final Class cCategory, final Class cService, final Class cLayer, final Class cMap, final Class cView, final Class cViewPort, final Class cSld)
{
this.langKeys=langKeys;
this.fGeo=fGeo;
this.cCategory=cCategory;
this.cService=cService;
this.cLayer=cLayer;
efLang = EjbLangFactory.createFactory(cLang);
efDescription = EjbDescriptionFactory.createFactory(clDescription);
efCategory = EjbGeoCategoryFactory.factory(cCategory);
efService = EjbGeoServiceFactory.factory(cService);
efLayer = EjbGeoLayerFactory.factory(cLang,cLayer);
efMap = EjbGeoMapFactory.factory(cLang, cMap);
efView = EjbGeoViewFactory.factory(cView);
efViewPort = EjbGeoViewPortFactory.factory(cViewPort);
slds = fGeo.fGlobalSlds(cSld);
}
protected void reloadServices()
{
services = fGeo.all(cService);
}
public void addService() throws UtilsConstraintViolationException
{
service = efService.build(null, null);
service.setName(efLang.createEmpty(langKeys));
service.setDescription(efDescription.createEmpty(langKeys));
layer=null;
category = null;
viewPort=null;
}
public void selectService() throws UtilsNotFoundException
{
service = fGeo.load(cService,service);
logger.info("selectService "+service);
layer=null;
category = null;
viewPort=null;
}
public void rm(SERVICE item)
{
logger.info("rm "+item);
try
{
fGeo.rm(item);
layer=null;
service=null;
reloadServices();
}
catch (UtilsConstraintViolationException e)
{
FacesContextMessage.warn("WARN", "uieServiceWithLayer");
}
}
public void saveService() throws UtilsConstraintViolationException, UtilsLockingException
{
logger.info("saveService "+service);
service = fGeo.save(service);
reloadServices();
}
public void cancelService() throws UtilsConstraintViolationException, UtilsLockingException
{
service=null;
category=null;
viewPort=null;
}
// CATEGORY
protected void reloadCategories()
{
categories = fGeo.allOrderedPositionVisible(cCategory);
}
public void addCategory() throws UtilsConstraintViolationException
{
logger.info("ADD CAtegory");
category = efCategory.build(null);
category.setName(efLang.createEmpty(langKeys));
category.setDescription(efDescription.createEmpty(langKeys));
service=null;
}
public void selectCategory() throws UtilsNotFoundException
{
category = fGeo.load(cCategory,category);
logger.info("selectCategory "+category);
reloadLayers();
layer=null;
service=null;
viewPort=null;
}
public void rm(CATEGORY item)
{
logger.info("rm "+item);
try
{
fGeo.rm(item);
reloadCategories();
category=null;
service=null;
}
catch (UtilsConstraintViolationException e)
{
FacesContextMessage.warn("WARN", "uieServiceWithLayer");
}
}
public void saveCategory() throws UtilsConstraintViolationException, UtilsLockingException
{
logger.info("saveCategory "+category);
category = fGeo.save(category);
reloadCategories();
service=null;
}
public void cancelCategory()
{
category=null;
service=null;
layer=null;
viewPort=null;
}
protected void reorderCategories() throws UtilsConstraintViolationException, UtilsLockingException
{
PositionListReorderer.reorder(fGeo, categories);
}
protected void reloadLayers()
{
category = fGeo.load(cCategory, category);
layers = fGeo.allOrderedPositionVisibleParent(cLayer, category);;
logger.info("#Layer:"+layers.size());
}
public void addLayer() throws UtilsConstraintViolationException, UtilsNotFoundException
{
logger.info("addLayer ");
layer = efLayer.build(null, service,category,langKeys);
layer.setDescription(efDescription.createEmpty(langKeys));
}
public void selectLayer() throws UtilsNotFoundException, UtilsConstraintViolationException, UtilsLockingException
{
logger.info("selectLayer "+layer);
layer = fGeo.load(cLayer,layer);
if(layer.getViewPort()==null){addViewPort();}
else{viewPort=layer.getViewPort();}
VIEW view = efView.build();
view.setLayer(layer);
view.setVisible(true);
map = efMap.build();
map.getViews().add(view);
}
public void saveLayer() throws UtilsConstraintViolationException, UtilsLockingException, UtilsNotFoundException
{
logger.info("saveLayer "+layer);
layer.setService(fGeo.find(cService, layer.getService()));
layer.setCategory(fGeo.find(cCategory, layer.getCategory()));
layer = fGeo.save(layer);
reloadLayers();
selectLayer();
}
public void rmLayer()
{
logger.info("rm "+layer);
fGeo.rm(cLayer,layer);
reloadLayers();
layer=null;
viewPort=null;
}
public void cancelLayer()
{
layer=null;
viewPort=null;
}
protected void reorderLayer() throws UtilsConstraintViolationException, UtilsLockingException
{
PositionListReorderer.reorder(fGeo, layers);
}
// View Port
private void addViewPort() throws UtilsConstraintViolationException, UtilsLockingException
{
viewPort = efViewPort.build();
viewPort = fGeo.save(viewPort);
layer.setViewPort(viewPort);
layer = fGeo.update(layer);
}
public void mapMove(MapAjaxEvent evt)
{
logger.info("Viewport: "+evt.getViewPort().getLat() +"/" +evt.getViewPort().getLon() +" in bounds of " +evt.getViewPort().getTop() +" and " +evt.getViewPort().getBottom());
efViewPort.update(viewPort,evt.getViewPort());
}
public void saveViewPort() throws UtilsConstraintViolationException, UtilsLockingException
{
logger.info(AbstractLogMessage.saveEntity(viewPort));
viewPort = fGeo.save(viewPort);
}
}