Minor Updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@92557 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-03-03 14:19:35 +00:00
parent bdf65644cc
commit 58c3f5d8ff
1 changed files with 100 additions and 20 deletions

View File

@ -845,23 +845,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
HttpSession session) {
String filter = SessionUtil.getCodelistsPagingLoadedFilter(session);
ArrayList<TabResource> ltrCopy = new ArrayList<TabResource>();
SessionUtil.setCodelistsPagingLoadedFilter(session, plc.getFilter());
if (filter == null) {
logger.debug("No filter filter present in session");
logger.debug("New Filter: " + plc.getFilter());
if (plc.getFilter() == null || plc.getFilter().isEmpty()) {
SessionUtil.setCodelistsPagingLoadedFilteredCopy(session, ltr);
return ltr;
} else {
for (TabResource tr : ltr) {
if (tr.getName().contains(plc.getFilter())) {
if (tr.getName() != null && !tr.getName().isEmpty()
&& tr.getName().contains(plc.getFilter())) {
ltrCopy.add(tr);
continue;
} else {
if (tr.getAgency().contains(plc.getFilter())) {
if (tr.getAgency() != null && !tr.getAgency().isEmpty()
&& tr.getAgency().contains(plc.getFilter())) {
ltrCopy.add(tr);
continue;
} else {
}
}
}
SessionUtil.setCodelistsPagingLoadedFilteredCopy(session,
@ -870,12 +876,12 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
}
} else {
logger.debug("Old Filter:" + filter);
logger.debug("New Filter: " + plc.getFilter());
if (plc.getFilter() == null || plc.getFilter().isEmpty()) {
SessionUtil.setCodelistsPagingLoadedFilter(session,plc.getFilter());
SessionUtil.setCodelistsPagingLoadedFilteredCopy(session, ltr);
return ltr;
} else {
if (filter.compareTo(plc.getFilter()) == 0) {
@ -883,27 +889,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
.getCodelistsPagingLoadedFilteredCopy(session);
return ltrFilteredCopy;
} else {
SessionUtil.setCodelistsPagingLoadedFilter(session,plc.getFilter());
for (TabResource tr : ltr) {
if (tr.getName().contains(plc.getFilter())) {
if (tr.getName() != null && !tr.getName().isEmpty()
&& tr.getName().contains(plc.getFilter())) {
ltrCopy.add(tr);
continue;
} else {
if (tr.getAgency().contains(plc.getFilter())) {
if (tr.getAgency() != null
&& !tr.getAgency().isEmpty()
&& tr.getAgency().contains(plc.getFilter())) {
ltrCopy.add(tr);
continue;
} else {
}
}
}
SessionUtil.setCodelistsPagingLoadedFilteredCopy(session,
ltrCopy);
return ltrCopy;
}
}
}
}
@ -920,14 +928,36 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
Collections.sort(ltrCopy, new Comparator<TabResource>() {
@Override
public int compare(TabResource tr1, TabResource tr2) {
return tr1.getName().compareTo(tr2.getName());
int comp = 0;
if (tr1.getName() == null) {
comp = -1;
} else {
if (tr2.getName() == null) {
comp = 1;
} else {
comp = tr1.getName().compareTo(
tr2.getName());
}
}
return comp;
}
});
} else {
Collections.sort(ltrCopy, new Comparator<TabResource>() {
@Override
public int compare(TabResource tr1, TabResource tr2) {
return -tr1.getName().compareTo(tr2.getName());
int comp = 0;
if (tr1.getName() == null) {
comp = -1;
} else {
if (tr2.getName() == null) {
comp = 1;
} else {
comp = tr1.getName().compareTo(
tr2.getName());
}
}
return -comp;
}
});
}
@ -943,8 +973,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
@Override
public int compare(TabResource tr1,
TabResource tr2) {
return tr1.getAgency().compareTo(
tr2.getAgency());
int comp = 0;
if (tr1.getAgency() == null) {
comp = -1;
} else {
if (tr2.getAgency() == null) {
comp = 1;
} else {
comp = tr1
.getAgency()
.compareTo(
tr2.getAgency());
}
}
return comp;
}
});
} else {
@ -953,8 +995,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
@Override
public int compare(TabResource tr1,
TabResource tr2) {
return -tr1.getAgency().compareTo(
tr2.getAgency());
int comp = 0;
if (tr1.getAgency() == null) {
comp = -1;
} else {
if (tr2.getAgency() == null) {
comp = 1;
} else {
comp = tr1
.getAgency()
.compareTo(
tr2.getAgency());
}
}
return -comp;
}
});
}
@ -968,8 +1022,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
@Override
public int compare(TabResource tr1,
TabResource tr2) {
return tr1.getDate().compareTo(
tr2.getDate());
int comp = 0;
if (tr1.getDate() == null) {
comp = -1;
} else {
if (tr2.getDate() == null) {
comp = 1;
} else {
comp = tr1
.getDate()
.compareTo(
tr2.getDate());
}
}
return comp;
}
});
} else {
@ -978,8 +1045,21 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
@Override
public int compare(TabResource tr1,
TabResource tr2) {
return -tr1.getDate().compareTo(
tr2.getDate());
int comp = 0;
if (tr1.getDate() == null) {
comp = -1;
} else {
if (tr2.getDate() == null) {
comp = 1;
} else {
comp = tr1
.getDate()
.compareTo(
tr2.getDate());
}
}
return -comp;
}
});
}