/** * Print a removed column annotation. * * @param column column from which the annotation was removed. * @param removedKey removed annotation key. */ private void printRemovedColumnAnnotation( final FijiColumnName column, final String removedKey ) { getPrintStream().printf("column: '%s'%n '%s'", column, removedKey); }
/** * Print several column annotations with the same key. * * @param key the key for all annotations. * @param cvs a map from columns to the value at the given annotation key. */ private void printColumnAnnotations( final String key, final Map<FijiColumnName, String> cvs ) { for (Map.Entry<FijiColumnName, String> cvEntry : cvs.entrySet()) { printColumnAnnotation(cvEntry.getKey(), key, cvEntry.getValue()); } }
/** * Print several columns and annotations associated with those columns. * * @param ckvs a mapping from column to key to value. */ private void printColumnAnnotations( final Map<FijiColumnName, Map<String, String>> ckvs ) { for (Map.Entry<FijiColumnName, Map<String, String>> columnEntry : ckvs.entrySet()) { printColumnAnnotations(columnEntry.getKey(), columnEntry.getValue()); } }
if (mMapFlag.isEmpty()) { mAnnotator.setTableAnnotation(mKeyFlag, mValueFlag); getPrintStream().println("Annotation added:"); printTableAnnotation(mKeyFlag, mValueFlag); } else { final Map<String, String> kvs = mapFromJson(mMapFlag); mAnnotator.setTableAnnotations(kvs); getPrintStream().println("Annotations added:"); printTableAnnotations(kvs); if (mMapFlag.isEmpty()) { mAnnotator.setColumnAnnotation(column, mKeyFlag, mValueFlag); getPrintStream().println("Annotation added:"); printColumnAnnotation(column, mKeyFlag, mValueFlag); } else { final Map<String, String> kvs = mapFromJson(mMapFlag); mAnnotator.setColumnAnnotations(column, kvs); getPrintStream().println("Annotations added:"); printColumnAnnotations(column, kvs);
if (mKeyFlag.isEmpty()) { if (mAllColumnsFlag) { getPrintStream().println("Annotations removed:"); printRemovedColumnAnnotations(mAnnotator.removeAllColumnAnnotations()); } else { if (!mFamilyFlag.isEmpty()) { getPrintStream().println("Annotations removed:"); printRemovedColumnAnnotations( mAnnotator.removeAllColumnAnnotationsInFamily(mFamilyFlag)); } else { getPrintStream().println("Annotations removed:"); printRemovedTableAnnotations(mAnnotator.removeAllTableAnnotations()); if (mFamilyFlag.isEmpty()) { if (mPrefixFlag) { getPrintStream().println("Annotations removed:"); printRemovedTableAnnotations(mAnnotator.removeTableAnnotationsStartingWith(mKeyFlag)); } else if (mPartialFlag) { getPrintStream().println("Annotations removed:"); printRemovedTableAnnotations(mAnnotator.removeTableAnnotationsContaining(mKeyFlag)); } else if (mRegexFlag) { getPrintStream().println("Annotations removed:"); printRemovedTableAnnotations(mAnnotator.removeTableAnnotationsMatching(mKeyFlag)); } else { getPrintStream().println("Annotation removed:"); mAnnotator.removeTableAnnotation(mKeyFlag); printRemovedTableAnnotation(mKeyFlag); getPrintStream().println("Annotations removed:");
if (mKeyFlag.isEmpty()) { if (mAllColumnsFlag) { printColumnAnnotations(mAnnotator.getAllColumnAnnotations()); } else { if (!mFamilyFlag.isEmpty()) { printColumnAnnotations(mAnnotator.getAllColumnAnnotationsInFamily(mFamilyFlag)); } else { printTableAnnotations(mAnnotator.getAllTableAnnotations()); if (mFamilyFlag.isEmpty()) { if (mPrefixFlag) { printTableAnnotations(mAnnotator.getTableAnnotationsStartingWith(mKeyFlag)); } else if (mPartialFlag) { printTableAnnotations(mAnnotator.getTableAnnotationsContaining(mKeyFlag)); } else if (mRegexFlag) { printTableAnnotations(mAnnotator.getTableAnnotationsMatching(mKeyFlag)); } else { printTableAnnotation(mKeyFlag, mAnnotator.getTableAnnotation(mKeyFlag)); printColumnAnnotations( mAnnotator.getColumnAnnotationsInFamilyStartingWith(mFamilyFlag, mKeyFlag)); } else if (mPartialFlag) { printColumnAnnotations( mAnnotator.getColumnAnnotationsInFamilyContaining(mFamilyFlag, mKeyFlag)); } else if (mRegexFlag) { printColumnAnnotations( mAnnotator.getColumnAnnotationsInFamilyMatching(mFamilyFlag, mKeyFlag)); } else { printColumnAnnotations(
mURI = FijiURI.newBuilder(mTargetFlag).build(); } catch (FijiURIException kurie) { exitWithErrorMessage(kurie.getMessage()); exitWithFormattedErrorMessage("--target URI must specify at least a table, got: '%s'", mURI); exitWithErrorMessage("--target URI must include one or zero columns."); exitWithFormattedErrorMessage( "Invalid --do command: '%s'. Valid commands are set, remove, get", mDoFlag); case SET: { if (mPrefixFlag || mPartialFlag || mRegexFlag) { exitWithErrorMessage("Cannot specify --prefix, --partial, or --regex while --do=set"); exitWithErrorMessage("Cannot specify a family with --in-family while --do=set"); exitWithErrorMessage("--do=set requires --key and --value OR --map"); exitWithErrorMessage("--map is mutually exclusive with --key and --value"); if (moreThanOne(mPrefixFlag, mPartialFlag, mRegexFlag)) { exitWithErrorMessage("Cannot specify more than one of --prefix, --partial, and --regex"); exitWithErrorMessage("Cannot specify --map while --do=remove"); exitWithErrorMessage("Cannot specify --value while --do=remove"); if (moreThanOne(mPrefixFlag, mPartialFlag, mRegexFlag)) {
/** {@inheritDoc} */ @Override protected int run(final List<String> nonFlagArgs) throws Exception { final Fiji fiji = Fiji.Factory.open(mURI); try { final FijiTable table = fiji.openTable(mURI.getTable()); try { mAnnotator = table.openTableAnnotator(); try { switch (mDoMode) { case SET: return set(); case REMOVE: return remove(); case GET: return get(); default: throw new InternalFijiError("Unknown NotesTool DoMode: " + mDoMode); } } finally { mAnnotator.close(); } } finally { table.release(); } } finally { fiji.release(); } } }
/** * Print several removed annotations from several columns. * * @param removedKeys map from column to annotation keys removed from that column. */ private void printRemovedColumnAnnotations( final Map<FijiColumnName, Set<String>> removedKeys ) { for (Map.Entry<FijiColumnName, Set<String>> columnEntry : removedKeys.entrySet()) { printRemovedColumnAnnotations(columnEntry.getKey(), columnEntry.getValue()); } }
/** * Print several removed annotations from a single column. * * @param column column from which annotations were removed. * @param removedKeys removed annotation keys. */ private void printRemovedColumnAnnotations( final FijiColumnName column, final Set<String> removedKeys ) { getPrintStream().printf("column: '%s'%n", column); for (String key: removedKeys) { getPrintStream().printf(" '%s'%n", key); } }
/** * Print a column and an annotation key value. * * @param column the annotated column. * @param key the annotation key. * @param value the annotation value. */ private void printColumnAnnotation( final FijiColumnName column, final String key, final String value ) { getPrintStream().printf("column: '%s'%n" + " '%s': '%s'%n", column, key, value); }
/** * Print several removed table annotations. * * @param removedKeys the set of removed annotation keys. */ private void printRemovedTableAnnotations( final Set<String> removedKeys ) { getPrintStream().printf("table: '%s'%n", mURI.getTable()); for (String key : removedKeys) { getPrintStream().printf(" '%s'%n", key); } }
/** * Print a column and several annotation key values. * * @param column the annotated column. * @param kvs a mapping of the keys and values. */ private void printColumnAnnotations( final FijiColumnName column, final Map<String, String> kvs ) { getPrintStream().printf("column: '%s'%n", column); for (Map.Entry<String, String> kv: kvs.entrySet()) { getPrintStream().printf(" '%s': '%s'%n", kv.getKey(), kv.getValue()); } }
/** * Print several annotation key values on the table specified in mURI. * * @param kvs a mapping of keys and values. */ private void printTableAnnotations( final Map<String, String> kvs ) { getPrintStream().printf("table: '%s'%n", mURI.getTable()); for (Map.Entry<String, String> kv : kvs.entrySet()) { getPrintStream().printf(" '%s': '%s'%n", kv.getKey(), kv.getValue()); } }
/** * Print an annotation on the table specified in mURI. * * @param key the annotation key. * @param value the annotation value. */ private void printTableAnnotation( final String key, final String value ) { getPrintStream().printf("table: '%s'%n" + " '%s': '%s'%n", mURI.getTable(), key, value); }
/** * Print a removed table annotation. * * @param removedKey the removed annotation key. */ private void printRemovedTableAnnotation( final String removedKey ) { getPrintStream().printf("table: '%s'%n '%s'%n", mURI.getTable(), removedKey); }