Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed May 31, 2018
1 parent 2290009 commit be8ae79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 35 deletions.
Expand Up @@ -18,8 +18,8 @@
*/
package org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table;

import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.common.lib.to.AttrTO;
import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
Expand Down Expand Up @@ -49,29 +49,25 @@ public AttrColumn(final String name, final SchemaType schemaType) {
public void populateItem(
final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> rowModel) {

List<String> values = null;
List<String> values = new ArrayList<>();

AttrTO attr = null;
switch (schemaType) {
case PLAIN:
attr = rowModel.getObject().getPlainAttr(name).get();
rowModel.getObject().getPlainAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
break;

case DERIVED:
attr = rowModel.getObject().getDerAttr(name).get();
rowModel.getObject().getDerAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
break;

case VIRTUAL:
attr = rowModel.getObject().getVirAttr(name).get();
rowModel.getObject().getVirAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
break;

default:
}
if (attr != null) {
values = attr.getValues();
}

if (values == null || values.isEmpty()) {
if (values.isEmpty()) {
cellItem.add(new Label(componentId, ""));
} else if (values.size() == 1) {
cellItem.add(new Label(componentId, values.get(0)));
Expand Down
Expand Up @@ -21,7 +21,6 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -147,6 +146,7 @@ public void delete(final SchemaType schemaType, final String schemaKey) {

@PreAuthorize("isAuthenticated()")
@Transactional(readOnly = true)
@SuppressWarnings("unchecked")
public <T extends SchemaTO> List<T> search(
final SchemaType schemaType, final List<String> anyTypeClasses, final String keyword) {

Expand All @@ -171,29 +171,17 @@ public <T extends SchemaTO> List<T> search(
? keyword == null
? virSchemaDAO.findAll()
: virSchemaDAO.findByKeyword(keyword)
: virSchemaDAO.findByAnyTypeClasses(classes)).
stream().map(new Function<VirSchema, T>() {

@Override
public T apply(final VirSchema schema) {
return (T) binder.getVirSchemaTO(schema);
}
}).collect(Collectors.toList());
: virSchemaDAO.findByAnyTypeClasses(classes)).stream().
map(schema -> (T) binder.getVirSchemaTO(schema)).collect(Collectors.toList());
break;

case DERIVED:
result = (classes.isEmpty()
? keyword == null
? derSchemaDAO.findAll()
: derSchemaDAO.findByKeyword(keyword)
: derSchemaDAO.findByAnyTypeClasses(classes)).
stream().map(new Function<DerSchema, T>() {

@Override
public T apply(final DerSchema schema) {
return (T) binder.getDerSchemaTO(schema);
}
}).collect(Collectors.toList());
: derSchemaDAO.findByAnyTypeClasses(classes)).stream().
map(schema -> (T) binder.getDerSchemaTO(schema)).collect(Collectors.toList());
break;

case PLAIN:
Expand All @@ -202,14 +190,8 @@ public T apply(final DerSchema schema) {
? keyword == null
? plainSchemaDAO.findAll()
: plainSchemaDAO.findByKeyword(keyword)
: plainSchemaDAO.findByAnyTypeClasses(classes)).
stream().map(new Function<PlainSchema, T>() {

@Override
public T apply(final PlainSchema schema) {
return (T) binder.getPlainSchemaTO(schema);
}
}).collect(Collectors.toList());
: plainSchemaDAO.findByAnyTypeClasses(classes)).stream().
map(schema -> (T) binder.getPlainSchemaTO(schema)).collect(Collectors.toList());
}

return result;
Expand Down

0 comments on commit be8ae79

Please sign in to comment.