protected List<Identifiable> loadAllEntries() { // There WAS a fix for Fix for OAUTH-119, skipping null identifiers, but the store should // now take care of this edge case. I am keeping the JIRA issue number here for future reference. allEntries = getStore().getAll(); return allEntries; }
public void size(InputLine inputLine) { if (showHelp(inputLine)) { showSizeHelp(); return; } sayi("Current store has " + getStore().size() + " entries"); }
/** * Resolves the first argument of a command line into either a unique identifier * * @param inputLine * @return */ protected Identifiable findItem(InputLine inputLine) { // first case is one in which this does not apply since there is no argument. if (inputLine.size() <= 1) { return null; } if (inputLine.getLastArg().startsWith("/")) { // then try to process this as a unique identifier. String arg = inputLine.getLastArg().substring(1); Identifier id = BasicIdentifier.newID(arg); return (Identifiable) getStore().get(id); } int choice = inputLine.getIntArg(inputLine.size() - 1); if (allEntries == null || allEntries.isEmpty()) { loadAllEntries(); // just in case... } return allEntries.get(choice); }
public void rm(InputLine inputLine) { if (showHelp(inputLine)) { showRMHelp(); return; } Identifiable x = findItem(inputLine); getStore().remove(x.getIdentifier()); say("Done. object with id = " + x.getIdentifierString() + " has been removed from the store"); info("Removed object " + x.getClass().getSimpleName() + " with id " + x.getIdentifierString()); clearEntries(); }
c = getStore().create(); if (getStore().containsKey(id)) { throw new IllegalArgumentException("Error: the identifier \"" + id + "\" is already in use."); getStore().save(c); info("Created object " + c.getClass().getSimpleName() + " with identifier " + c.getIdentifierString()); sayi("Object created with identifier " + c.getIdentifierString()); getStore().save(c); clearEntries();
try { id = BasicIdentifier.newID(inputLine.getArg(1)); if (getStore().containsKey(id)) { throw new IllegalArgumentException("Error: The identifier \"" + id + "\" already has an entry in this store."); Identifiable x = getStore().create(); x.setIdentifier(id); getStore().save(x); info("Created and saved " + x.getClass().getSimpleName() + " with id " + x.getIdentifierString()); say("Created object with id \"" + x.getIdentifier() + "\""); info("updated object with id " + x.getIdentifierString()); getStore().save(x); clearEntries();
public void update(InputLine inputLine) { if (showHelp(inputLine)) { showUpdateHelp(); return; } if (inputLine.size() == 1) { say("You must supply the index or id of the item to update"); return; } Identifiable identifiable = findItem(inputLine); if (identifiable != null) { // Note that the contract should be that a clone is passed in and that is saved if the user // decides to. Identifiable identifiable1 = identifiable.clone(); if (update(identifiable1)) { getStore().save(identifiable1); clearEntries(); // CIL-240: Remove entries so the updated item is displayed. } return; } say("no object with that index or id found. Please try again"); }