Commit 9cad2d91 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

old code removed

parent 9b9c33ed
package lcsb.mapviewer.web.converter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.WeakHashMap;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Converter used for {@link lcsb.mapviewer.model.map.MiriamType} in primefaces
* pick list.
*
* @author Piotr Gawron
*
*/
@FacesConverter(value = "miriamTypeConverter")
public class MiriamTypeConverter implements Converter {
/**
* Map between custom uuid and MiriamType object.
*/
private static Map<Object, String> entities = new WeakHashMap<Object, String>();
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private Logger logger = LogManager.getLogger();
@Override
public Object getAsObject(FacesContext context, UIComponent component, String uuid) {
for (Entry<Object, String> entry : entities.entrySet()) {
if (entry.getValue().equals(uuid)) {
return entry.getKey();
}
}
return null;
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object entity) {
synchronized (entities) {
if (!entities.containsKey(entity)) {
String uuid = UUID.randomUUID().toString();
entities.put(entity, uuid);
return uuid;
} else {
return entities.get(entity);
}
}
}
}
/**
* Provides {@link javax.faces.convert.Converter converters} for components used
* by primefaces.
*/
package lcsb.mapviewer.web.converter;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment