Java Code Examples for org.pentaho.di.repository.ObjectId#equals()
The following examples show how to use
org.pentaho.di.repository.ObjectId#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UIRepositoryDirectory.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null ) { return false; } if ( getClass() != obj.getClass() ) { return false; } UIRepositoryDirectory other = (UIRepositoryDirectory) obj; ObjectId id = getObjectId(); ObjectId otherId = other.getObjectId(); if ( id == null ) { if ( otherId != null ) { return false; } } else if ( !id.equals( otherId ) ) { return false; } return true; }
Example 2
Source File: ObjectIdLoadSaveValidator.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public boolean validateTestObject( ObjectId testObject, Object actual ) { if ( !( actual instanceof ObjectId ) ) { return false; } ObjectId actualInput = (ObjectId) actual; return ( testObject.equals( actualInput ) ); }
Example 3
Source File: KettleDatabaseRepositoryDirectoryDelegate.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Move / rename a directory in the repository * * @param id_directory * Id of the directory to be moved/renamed * @param id_directory_parent * Id of the new parent directory (null if the parent does not change) * @param newName * New name for this directory (null if the name does not change) * @throws KettleException */ public synchronized void renameDirectory( ObjectId id_directory, ObjectId id_directory_parent, String newName ) throws KettleException { if ( id_directory.equals( id_directory_parent ) ) { // Make sure the directory cannot become its own parent throw new KettleException( "Failed to copy directory into itself" ); } else { // Make sure the directory does not become a descendant of itself RepositoryDirectory rd = new RepositoryDirectory(); loadRepositoryDirectory( rd, id_directory ); if ( rd.findDirectory( id_directory_parent ) != null ) { // The parent directory is a child of this directory. Do not proceed throw new KettleException( "Directory cannot become a child to itself" ); } else { // Check for duplication RepositoryDirectory newParent = new RepositoryDirectory(); loadRepositoryDirectory( newParent, id_directory_parent ); RepositoryDirectory child = newParent.findChild( newName == null ? rd.getName() : newName ); if ( child != null ) { throw new KettleException( "Destination directory already contains a diectory with requested name" ); } } } if ( id_directory_parent != null || newName != null ) { RowMetaAndData r = new RowMetaAndData(); String sql = "UPDATE " + quoteTable( KettleDatabaseRepository.TABLE_R_DIRECTORY ) + " SET "; boolean additionalParameter = false; if ( newName != null ) { additionalParameter = true; sql += quote( KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ) + " = ?"; r.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ), newName ); } if ( id_directory_parent != null ) { // Add a parameter separator if the first parm was added if ( additionalParameter ) { sql += ", "; } sql += quote( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ) + " = ?"; r.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ), id_directory_parent ); } sql += " WHERE " + quote( KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY ) + " = ? "; r.addValue( new ValueMetaInteger( "id_directory" ), Long.valueOf( id_directory .toString() ) ); repository.connectionDelegate.getDatabase().execStatement( sql, r.getRowMeta(), r.getData() ); } }
Example 4
Source File: PurRepository.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * Do not call this method directly. Instead call updateSharedObjectCache or removeFromSharedObjectCache. */ private void updateSharedObjectCache( final RepositoryElementInterface element, final RepositoryObjectType type, final ObjectId id ) throws KettleException { if ( element != null && ( element.getObjectId() == null || element.getObjectId().getId() == null ) ) { throw new IllegalArgumentException( element.getName() + " has a null id" ); } loadAndCacheSharedObjects( false ); boolean remove = element == null; ObjectId idToFind = element != null ? element.getObjectId() : id; RepositoryObjectType typeToUpdate = element != null ? element.getRepositoryElementType() : type; RepositoryElementInterface elementToUpdate = null; List<? extends SharedObjectInterface> origSharedObjects = null; sharedObjectsLock.writeLock().lock(); try { switch ( typeToUpdate ) { case DATABASE: origSharedObjects = sharedObjectsByType.get( RepositoryObjectType.DATABASE ); if ( !remove ) { elementToUpdate = (RepositoryElementInterface) ( (DatabaseMeta) element ).clone(); } break; case SLAVE_SERVER: origSharedObjects = sharedObjectsByType.get( RepositoryObjectType.SLAVE_SERVER ); if ( !remove ) { elementToUpdate = (RepositoryElementInterface) ( (SlaveServer) element ).clone(); } break; case CLUSTER_SCHEMA: origSharedObjects = sharedObjectsByType.get( RepositoryObjectType.CLUSTER_SCHEMA ); if ( !remove ) { elementToUpdate = ( (ClusterSchema) element ).clone(); } break; case PARTITION_SCHEMA: origSharedObjects = sharedObjectsByType.get( RepositoryObjectType.PARTITION_SCHEMA ); if ( !remove ) { elementToUpdate = (RepositoryElementInterface) ( (PartitionSchema) element ).clone(); } break; default: throw new KettleException( "unknown type [" + typeToUpdate + "]" ); } List<SharedObjectInterface> newSharedObjects = new ArrayList<SharedObjectInterface>( origSharedObjects ); // if there's a match on id, replace the element boolean found = false; for ( int i = 0; i < origSharedObjects.size(); i++ ) { RepositoryElementInterface repositoryElementInterface = (RepositoryElementInterface) origSharedObjects.get( i ); if ( repositoryElementInterface == null ) { continue; } ObjectId objectId = repositoryElementInterface.getObjectId(); if ( objectId != null && objectId.equals( idToFind ) ) { if ( remove ) { newSharedObjects.remove( i ); } else { elementToUpdate.setObjectId( idToFind ); // because some clones don't clone the ID!!! newSharedObjects.set( i, (SharedObjectInterface) elementToUpdate ); } found = true; } } // otherwise, add it if ( !remove && !found ) { elementToUpdate.setObjectId( idToFind ); // because some clones don't clone the ID!!! newSharedObjects.add( (SharedObjectInterface) elementToUpdate ); } sharedObjectsByType.put( typeToUpdate, newSharedObjects ); } finally { sharedObjectsLock.writeLock().unlock(); } }