/** * Implements the --do=set operation. * * @param fiji Fiji instance. * @throws Exception on error. */ private void setLayout(Fiji fiji) throws Exception { final TableLayoutDesc layoutDesc = loadJsonTableLayoutDesc(mLayout); Preconditions.checkArgument(mTableURI.getTable().equals(layoutDesc.getName()), "Descriptor table name '%s' does not match URI %s.", layoutDesc.getName(), mTableURI); fiji.modifyTableLayout(layoutDesc, mDryRun, getPrintStream()); }
/** * Install the job history table into a Fiji instance. This should be called only * via open, because we might want to update the layout of the job history table. * * @param fiji The Fiji instance to install this table in. * @throws IOException If there is an error. */ private static void install(Fiji fiji) throws IOException { if (!fiji.getTableNames().contains(TABLE_NAME)) { // Try to install the job history table if necessary. fiji.createTable( FijiTableLayout.createFromEffectiveJsonResource(TABLE_LAYOUT_RESOURCE).getDesc()); } // At this point, we either have an existing table or we just installed a new // one. Check if the table is using the old layout, and update it if it is. if (fiji.getMetaTable().getTableLayout(TABLE_NAME).getDesc().getLayoutId() .equals(PREV_TABLE_LAYOUT_VERSION)) { FijiTableLayout ktl = FijiTableLayout .createFromEffectiveJsonResource(TABLE_LAYOUT_V2); fiji.modifyTableLayout(ktl.getDesc()); } // If there are further updates to the job history layout, they should probably be added here. }