use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.
the class ClientSorter method sortByID.
protected ArrayList<Identifiable> sortByID(List<Identifiable> arg) {
TreeMap<String, Identifiable> tm = new TreeMap<>();
for (int i = 0; i < arg.size(); i++) {
BaseClient client = (BaseClient) arg.get(i);
tm.put(client.getIdentifierString(), client);
}
return new ArrayList(tm.values());
}
use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.
the class ClientSorter method sortByDate.
protected ArrayList<Identifiable> sortByDate(List<Identifiable> arg) {
TreeMap<String, ArrayList<Identifiable>> tm = new TreeMap<>();
// allows for multiple values for each key and then returns everything.
for (int i = 0; i < arg.size(); i++) {
BaseClient client = (BaseClient) arg.get(i);
String key = Iso8601.date2String(client.getCreationTS());
if (tm.containsKey(key)) {
tm.get(key).add(client);
} else {
ArrayList<Identifiable> x = new ArrayList<>();
x.add(client);
tm.put(key, x);
}
}
// now we have to unpack any lists.
ArrayList<Identifiable> outList = new ArrayList<>();
for (String key : tm.keySet()) {
outList.addAll(tm.get(key));
}
return outList;
}
use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.
the class ClientStoreUtil method listAll.
@Override
protected LinkedList<Identifiable> listAll() throws Exception {
say("select the number of the item below:");
ClientApprovalStore cas = getSE().getClientApprovalStore();
Set keys = getStore().keySet();
LinkedList<Identifiable> linkedList = new LinkedList<Identifiable>();
int i = 0;
for (Object key : keys) {
boolean isApproved = false;
ClientApproval ca = (ClientApproval) cas.get(key);
if (ca == null) {
// create a new one
ca = (ClientApproval) cas.create();
ca.setStatus(ClientApproval.Status.NONE);
ca.setApproved(false);
cas.save(ca);
} else {
isApproved = ca.isApproved();
if (isApproved && ca.getStatus() != ClientApproval.Status.APPROVED) {
ca.setStatus(ClientApproval.Status.APPROVED);
}
}
ClientApproval.Status status = ca.getStatus();
String printableStatus = "?";
if (status.equals(ClientApproval.Status.NONE)) {
}
Identifiable x = (Identifiable) getStore().get(key);
linkedList.add(x);
say((i++) + "." + "(" + (isApproved ? "A" : "D") + ") " + x.getIdentifierString());
}
if (linkedList.isEmpty()) {
say("(no entries found)");
}
return linkedList;
}
use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.
the class BaseClientStoreCommands method rm.
@Override
public void rm(InputLine inputLine) {
sayi("Removing approval record");
Identifiable x = findItem(inputLine);
info("Removing approval record for id=" + x.getIdentifierString());
getClientApprovalStore().remove(x.getIdentifier());
sayi("Done. Client approval with id = " + x.getIdentifierString() + " has been removed from the store");
info("Client record removed for id=" + x.getIdentifierString());
super.rm(inputLine);
}
use of edu.uiuc.ncsa.security.core.Identifiable in project OA4MP by ncsa.
the class CopyToolVerifier method verifyStore.
public boolean verifyStore(String storeName, Store<? extends Identifiable> source, Store<? extends Identifiable> target) {
long srcSize = source.size();
if (srcSize != target.size()) {
say("Error: Source \"" + source + "\"(" + srcSize + ") and target \"" + target + "\"(" + target.size() + ") are not the same");
return false;
}
saynoCR("Checking store " + storeName + " with " + srcSize + " elements... ");
for (Identifier identifier : source.keySet()) {
if (!target.containsKey(identifier)) {
say("Error: Source store contains key " + "\"" + identifier + "\" and target store does not.");
return false;
}
Identifiable src = source.get(identifier);
if (src == null) {
say("Error: Failed getting source object with identifier \"" + identifier + "\"");
return false;
}
Identifiable trgt = target.get(identifier);
if (trgt == null) {
say("Error: Failed getting target object with identifier \"" + identifier + "\"");
return false;
}
if (!src.equals(trgt)) {
say("Error: source and target objects do not match!");
say("Source object:\n\n" + src.toString());
say("\nTarget object:\n\n" + trgt.toString());
return false;
}
}
say("ok!");
return true;
}
Aggregations