Commit 6ea5a508 authored by michael.simon's avatar michael.simon
Browse files

Update Primefaces to 8.0

parent 680ef950
......@@ -111,6 +111,19 @@
<artifactId>oauth2-oidc-sdk</artifactId>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<artifactId>dom4j</artifactId>
<groupId>dom4j</groupId>
......
......@@ -72,6 +72,22 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
......
......@@ -14,6 +14,8 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.primefaces.model.FilterMeta;
import edu.kit.scc.webreg.entity.BaseEntity;
public interface BaseDao<T extends BaseEntity<PK>, PK extends Serializable> {
......@@ -27,7 +29,7 @@ public interface BaseDao<T extends BaseEntity<PK>, PK extends Serializable> {
List<T> findAll();
List<T> findAllPaging(int first, int pageSize, String sortField, GenericSortOrder sortOrder,
Map<String, Object> filterMap, String... attrs);
Map<String, Object> filterMap, Map<String, FilterMeta> additionalFilterMap, String... attrs);
Number countAll(Map<String, Object> filterMap);
......
......@@ -30,6 +30,9 @@ import javax.persistence.criteria.Path;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import org.primefaces.model.FilterMeta;
import org.primefaces.model.MatchMode;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.GenericSortOrder;
import edu.kit.scc.webreg.dao.ops.AndPredicate;
......@@ -87,13 +90,14 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
@SuppressWarnings("unchecked")
@Override
public List<T> findAllPaging(int first, int pageSize, String sortField,
GenericSortOrder sortOrder, Map<String, Object> filterMap, String... attrs) {
GenericSortOrder sortOrder, Map<String, Object> filterMap, Map<String, FilterMeta> additionalFilterMap, String... attrs) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<T> criteria = builder.createQuery(getEntityClass());
Root<T> root = criteria.from(getEntityClass());
List<Predicate> predicates = predicatesFromFilterMap(builder, root, filterMap);
predicates.addAll(predicatesFromAdditionalFilterMap(builder, root, additionalFilterMap));
criteria.where(builder.and(predicates.toArray(new Predicate[predicates.size()])));
criteria.select(root);
......@@ -198,6 +202,45 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
}
protected List<Predicate> predicatesFromAdditionalFilterMap(CriteriaBuilder builder, Root<T> root, Map<String, FilterMeta> additionalFilterMap) {
List<Predicate> predicates = new ArrayList<Predicate>();
for (Entry<String, FilterMeta> entry : additionalFilterMap.entrySet()) {
if (entry.getValue() != null && entry.getValue().getFilterValue() != null) {
predicates.add(predicateFromFilterMeta(builder, root, entry.getKey(), entry.getValue()));
}
}
return predicates;
}
protected Predicate predicateFromFilterMeta(CriteriaBuilder builder, Root<T> root, String path, FilterMeta filterMeta) {
if (filterMeta.getFilterMatchMode().equals(MatchMode.STARTS_WITH)) {
return builder.like(
builder.lower(this.<String>resolvePath(root, path)),
filterMeta.getFilterValue().toString().toLowerCase() + "%");
}
else if (filterMeta.getFilterMatchMode().equals(MatchMode.ENDS_WITH)) {
return builder.like(
builder.lower(this.<String>resolvePath(root, path)),
"%" + filterMeta.getFilterValue().toString().toLowerCase());
}
else if (filterMeta.getFilterMatchMode().equals(MatchMode.CONTAINS)) {
return builder.like(
builder.lower(this.<String>resolvePath(root, path)),
"%" + filterMeta.getFilterValue().toString().toLowerCase() + "%");
}
else if (filterMeta.getFilterMatchMode().equals(MatchMode.EQUALS)) {
return builder.like(
builder.lower(this.<String>resolvePath(root, path)),
filterMeta.getFilterValue().toString().toLowerCase());
}
else {
return builder.equal(resolvePath(root, path), filterMeta.getFilterValue());
}
}
protected Predicate predicateFromObject(CriteriaBuilder builder, Root<T> root, String path, Object o) {
if (o instanceof MultipathOrPredicate) {
MultipathOrPredicate p = (MultipathOrPredicate) o;
......
......@@ -124,6 +124,22 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
......
......@@ -14,6 +14,8 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.primefaces.model.FilterMeta;
import edu.kit.scc.webreg.dao.GenericSortOrder;
import edu.kit.scc.webreg.entity.BaseEntity;
......@@ -34,7 +36,7 @@ public interface BaseService<T extends BaseEntity<PK>, PK extends Serializable>
T findByIdWithAttrs(PK id, String... attrs);
List<T> findAllPaging(int first, int pageSize, String sortField,
GenericSortOrder sortOrder, Map<String, Object> filterMap, String... attrs);
GenericSortOrder sortOrder, Map<String, Object> filterMap, Map<String, FilterMeta> additionalFilterMap, String... attrs);
Number countAll(Map<String, Object> filterMap);
......
......@@ -14,6 +14,8 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.primefaces.model.FilterMeta;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.GenericSortOrder;
import edu.kit.scc.webreg.entity.BaseEntity;
......@@ -52,8 +54,8 @@ public abstract class BaseServiceImpl<T extends BaseEntity<PK>, PK extends Seria
@Override
public List<T> findAllPaging(int first, int pageSize, String sortField,
GenericSortOrder sortOrder, Map<String, Object> filterMap, String... attrs) {
return getDao().findAllPaging(first, pageSize, sortField, sortOrder, filterMap, attrs);
GenericSortOrder sortOrder, Map<String, Object> filterMap, Map<String, FilterMeta> additionalFilterMap, String... attrs) {
return getDao().findAllPaging(first, pageSize, sortField, sortOrder, filterMap, additionalFilterMap, attrs);
}
@Override
......
......@@ -44,6 +44,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
......@@ -57,10 +58,12 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
......
......@@ -101,7 +101,7 @@ public class ImageGalleryBean implements Serializable {
image.setName(event.getFile().getFileName());
image.setImageType(ImageType.PNG);
image.getImageData().setData(IOUtils.toByteArray(event.getFile().getInputstream()));
image.getImageData().setData(IOUtils.toByteArray(event.getFile().getInputStream()));
imageService.save(image);
imageList = imageService.findAll();
......
......@@ -24,6 +24,7 @@ import javax.inject.Inject;
import org.opensaml.saml.saml2.core.Attribute;
import org.primefaces.event.TransferEvent;
import org.primefaces.model.DualListModel;
import org.primefaces.model.FilterMeta;
import org.primefaces.model.LazyDataModel;
import org.slf4j.Logger;
......
......@@ -97,7 +97,7 @@ public class TokenAdminIndexBean implements Serializable {
new PathObjectValue("surName", part),
new PathObjectValue("givenName", part)
));
return userService.findAllPaging(0, 10, "eppn", GenericSortOrder.ASC, filterMap);
return userService.findAllPaging(0, 10, "eppn", GenericSortOrder.ASC, filterMap, null);
}
public void enableToken(String serial) {
......
......@@ -14,6 +14,7 @@ import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.primefaces.model.FilterMeta;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;
......@@ -29,7 +30,7 @@ public class GenericLazyDataModelImpl<E extends BaseEntity<PK>, T extends BaseSe
private T service;
private Map<String, Object> additionalFilterMap;
private Map<String, Object> filterMap;
private String[] attrs;
public GenericLazyDataModelImpl(T service) {
......@@ -37,14 +38,14 @@ public class GenericLazyDataModelImpl<E extends BaseEntity<PK>, T extends BaseSe
this.service = service;
}
public GenericLazyDataModelImpl(T service, Map<String, Object> additionalFilterMap) {
public GenericLazyDataModelImpl(T service, Map<String, Object> filterMap) {
this(service);
this.additionalFilterMap = additionalFilterMap;
this.filterMap = filterMap;
}
public GenericLazyDataModelImpl(T service, Map<String, Object> additionalFilterMap, String... attrs) {
public GenericLazyDataModelImpl(T service, Map<String, Object> filterMap, String... attrs) {
this(service);
this.additionalFilterMap = additionalFilterMap;
this.filterMap = filterMap;
this.attrs = attrs;
}
......@@ -52,23 +53,19 @@ public class GenericLazyDataModelImpl<E extends BaseEntity<PK>, T extends BaseSe
this(service);
this.attrs = attrs;
}
@Override
public List<E> load(int first, int pageSize, String sortField,
SortOrder sortOrder, Map<String, Object> filterMap) {
if (filterMap != null && additionalFilterMap != null) {
filterMap.putAll(additionalFilterMap);
}
SortOrder sortOrder, Map<String, FilterMeta> additionalFilterMap) {
List<E> returnList;
if (sortOrder == SortOrder.ASCENDING)
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.ASC, filterMap, attrs);
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.ASC, filterMap, additionalFilterMap, attrs);
else if (sortOrder == SortOrder.DESCENDING)
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.DESC, filterMap, attrs);
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.DESC, filterMap, additionalFilterMap, attrs);
else
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.NONE, filterMap, attrs);
returnList = getService().findAllPaging(first, pageSize, sortField, GenericSortOrder.NONE, filterMap, additionalFilterMap, attrs);
setPageSize(pageSize);
......
......@@ -39,15 +39,15 @@
</f:facet>
<h:outputText value="#{registry.id}" />
</p:column>
<p:column sortBy="#{registry.user.eppn}" filterBy="#{registry.user.eppn}">
<p:column sortBy="#{registry.user.eppn}" filterBy="#{registry.user.eppn}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{messages.eppn}" />
</f:facet>
<h:link outcome="show-service-registry.xhtml" value="#{registry.user.eppn}">
<h:link outcome="show-service-registry.xhtml" value="#{registry.user.eppn}" filterMatchMode="contains">
<f:param name="id" value="#{registry.id}"/>
</h:link>
</p:column>
<p:column sortBy="#{registry.user.surName}" filterBy="#{registry.user.surName}">
<p:column sortBy="#{registry.user.surName}" filterBy="#{registry.user.surName}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{messages.sur_name}" />
</f:facet>
......
......@@ -68,7 +68,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>7.0</version>
<version>8.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
......@@ -83,7 +83,7 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
......@@ -232,7 +232,7 @@
<bwreg.faces.stage>Production</bwreg.faces.stage>
<bwreg.hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</bwreg.hibernate.dialect>
<bwreg.hibernate.datasource>java:/ds/bwidmDS</bwreg.hibernate.datasource>
<bwreg.theme>aristo</bwreg.theme>
<bwreg.theme>kit-theme</bwreg.theme>
<bwreg.css>std.css</bwreg.css>
<bwreg.template>layout-template.xhtml</bwreg.template>
<bwreg.template.head-bar>head-bar.xhtml</bwreg.template.head-bar>
......@@ -250,7 +250,7 @@
<bwreg.faces.stage>Development</bwreg.faces.stage>
<bwreg.hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</bwreg.hibernate.dialect>
<bwreg.hibernate.datasource>java:/ds/bwidmDS</bwreg.hibernate.datasource>
<bwreg.theme>aristo</bwreg.theme>
<bwreg.theme>kit-theme</bwreg.theme>
<bwreg.css>std.css</bwreg.css>
<bwreg.template>layout-template.xhtml</bwreg.template>
<bwreg.template.head-bar>head-bar.xhtml</bwreg.template.head-bar>
......@@ -272,7 +272,7 @@
<bwreg.faces.stage>Production</bwreg.faces.stage>
<bwreg.hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</bwreg.hibernate.dialect>
<bwreg.hibernate.datasource>java:/ds/bwidmDS</bwreg.hibernate.datasource>
<bwreg.theme>aristo</bwreg.theme>
<bwreg.theme>kit-theme</bwreg.theme>
<bwreg.css>std.css</bwreg.css>
<bwreg.template>layout-template.xhtml</bwreg.template>
<bwreg.template.head-bar>head-bar.xhtml</bwreg.template.head-bar>
......@@ -290,7 +290,7 @@
<bwreg.faces.stage>Development</bwreg.faces.stage>
<bwreg.hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</bwreg.hibernate.dialect>
<bwreg.hibernate.datasource>java:/ds/bwidmDS</bwreg.hibernate.datasource>
<bwreg.theme>aristo</bwreg.theme>
<bwreg.theme>kit-theme</bwreg.theme>
<bwreg.css>std.css</bwreg.css>
<bwreg.template>layout-template.xhtml</bwreg.template>
<bwreg.template.head-bar>head-bar.xhtml</bwreg.template.head-bar>
......
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