protected void replaceSharedObjects(TransMeta transMeta) throws KettleException { replaceSharedObjects((AbstractMeta) transMeta); for (ClusterSchema clusterSchema : getSharedObjects(ClusterSchema.class)) { int index = transMeta.getClusterSchemas().indexOf(clusterSchema); if (index < 0) { transMeta.getClusterSchemas().add(clusterSchema); } else { ClusterSchema imported = transMeta.getClusterSchemas().get(index); // Preserve the object id so we can update without having to look up the id imported.setObjectId(clusterSchema.getObjectId()); if (equals(clusterSchema, imported) || !getPromptResult( BaseMessages.getString( PKG, "RepositoryImporter.Dialog.ClusterSchemaExistsOverWrite.Message", imported.getName()), BaseMessages.getString( PKG, "RepositoryImporter.Dialog.ConnectionExistsOverWrite.DontShowAnyMoreMessage"), IMPORT_ASK_ABOUT_REPLACE_CS)) { imported.replaceMeta(clusterSchema); // We didn't actually change anything imported.clearChanged(); } else { imported.setChanged(); } } } for (PartitionSchema partitionSchema : getSharedObjects(PartitionSchema.class)) { int index = transMeta.getPartitionSchemas().indexOf(partitionSchema); if (index < 0) { transMeta.getPartitionSchemas().add(partitionSchema); } else { PartitionSchema imported = transMeta.getPartitionSchemas().get(index); // Preserve the object id so we can update without having to look up the id imported.setObjectId(partitionSchema.getObjectId()); if (equals(partitionSchema, imported) || !getPromptResult( BaseMessages.getString( PKG, "RepositoryImporter.Dialog.PartitionSchemaExistsOverWrite.Message", imported.getName()), BaseMessages.getString( PKG, "RepositoryImporter.Dialog.ConnectionExistsOverWrite.DontShowAnyMoreMessage"), IMPORT_ASK_ABOUT_REPLACE_PS)) { imported.replaceMeta(partitionSchema); // We didn't actually change anything imported.clearChanged(); } else { imported.setChanged(); } } } }
/** * Add clusters in the repository to this transformation if they are not yet present. * * @param TransMeta The transformation to load into. * @param overWriteShared if an object with the same name exists, overwrite */ protected void readClusters( TransMeta transMeta, boolean overWriteShared, List<ClusterSchema> clusterSchemas) { for (ClusterSchema clusterSchema : clusterSchemas) { if (overWriteShared || transMeta.findClusterSchema(clusterSchema.getName()) == null) { if (!Const.isEmpty(clusterSchema.getName())) { clusterSchema.shareVariablesWith(transMeta); transMeta.addOrReplaceClusterSchema(clusterSchema); if (!overWriteShared) { clusterSchema.setChanged(false); } } } } }