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