Do automaticky odesílaných e-mailů lze nyní vložit URL na záznam
požadavku. Při otevření URL se nastaví kurzor v gridu na příslušný záznam.Verze_1.0
parent
babb9f8312
commit
a9a98cfd63
@ -0,0 +1,39 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.DataModel;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class CommonUrlResolver implements EntityUrlResolver {
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
protected String defaultUrl;
|
||||
|
||||
public CommonUrlResolver() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String entityUrl(Object entity) {
|
||||
if (defaultUrl == null) {
|
||||
this.defaultUrl = request.getRequestURL().toString();
|
||||
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
|
||||
}
|
||||
|
||||
if (!DataModel.class.isAssignableFrom(entity.getClass())) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
String url = Constants.URL_MAP.get(entity.getClass());
|
||||
|
||||
if (url == null) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
return defaultUrl + url + "?select=" + String.valueOf(((DataModel)entity).getId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
public interface EntityUrlResolver {
|
||||
|
||||
public String entityUrl(Object entity);
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class RequirementUrlResolver implements EntityUrlResolver {
|
||||
|
||||
private String defaultUrl;
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
public RequirementUrlResolver() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String entityUrl(Object entity) {
|
||||
if (!(entity instanceof Requirement)) {
|
||||
return defaultUrl + "/app";
|
||||
}
|
||||
|
||||
if (defaultUrl == null) {
|
||||
this.defaultUrl = request.getRequestURL().toString();
|
||||
this.defaultUrl = defaultUrl.substring(0, defaultUrl.indexOf(request.getServletPath()));
|
||||
}
|
||||
|
||||
Requirement req = (Requirement)entity;
|
||||
|
||||
if (req.getKind() == Constants.REQ_TYPE_MATERIAL) {
|
||||
return defaultUrl + Constants.URL_MAP.get(req) + "material/?select=" + String.valueOf(req.getId());
|
||||
} else {
|
||||
return defaultUrl + Constants.URL_MAP.get(req) + "services/?select=" + String.valueOf(req.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UrlResolverHolder {
|
||||
|
||||
private EntityUrlResolver commonResolver;
|
||||
private Map<Class<?>, EntityUrlResolver> resolvers;
|
||||
|
||||
public UrlResolverHolder(EntityUrlResolver common) {
|
||||
this.commonResolver = common;
|
||||
resolvers = new HashMap<Class<?>, EntityUrlResolver>();
|
||||
}
|
||||
|
||||
public void setResolvers(Map<Class<?>, EntityUrlResolver> resolvers) {
|
||||
this.resolvers = resolvers;
|
||||
}
|
||||
|
||||
public EntityUrlResolver resolverFor(Class<?> clazz) {
|
||||
EntityUrlResolver res = resolvers.get(clazz);
|
||||
|
||||
if (res == null) {
|
||||
return commonResolver;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue