/** * Returns a list of codes for the given collection of IdentifiableObjects. * * @param objects the list of IdentifiableObjects. * @return a list of codes. */ public static <T extends IdentifiableObject> List<String> getCodes( Collection<T> objects ) { return objects != null ? objects.stream().map( o -> o.getCode() ).collect( Collectors.toList() ) : null; }
public DeletedObjectQuery( IdentifiableObject identifiableObject ) { Assert.notNull( identifiableObject, "identifiableObject is a required parameter and can not be null." ); klass.add( ClassUtils.getShortName( identifiableObject.getClass() ) ); uid.add( identifiableObject.getUid() ); if ( !StringUtils.isEmpty( identifiableObject.getCode() ) ) { code.add( identifiableObject.getCode() ); } }
public MetadataAuditQuery( IdentifiableObject identifiableObject ) { Assert.notNull( identifiableObject, "identifiableObject is a required parameter and can not be null." ); klass.add( ClassUtils.getShortName( identifiableObject.getClass() ) ); uid.add( identifiableObject.getUid() ); if ( !StringUtils.isEmpty( identifiableObject.getCode() ) ) { code.add( identifiableObject.getCode() ); } }
@SuppressWarnings( "incomplete-switch" ) public <T extends IdentifiableObject> String getIdentifier( T object ) { switch ( this ) { case UID: return object.getUid(); case CODE: return object.getCode(); } throw new RuntimeException( "Unhandled identifier type." ); }
@SuppressWarnings( "unchecked" ) private void addIdentifiers( Map<PreheatIdentifier, Map<Class<? extends IdentifiableObject>, Set<String>>> map, IdentifiableObject identifiableObject ) { if ( identifiableObject == null ) return; Map<Class<? extends IdentifiableObject>, Set<String>> uidMap = map.get( PreheatIdentifier.UID ); Map<Class<? extends IdentifiableObject>, Set<String>> codeMap = map.get( PreheatIdentifier.CODE ); Class<? extends IdentifiableObject> klass = (Class<? extends IdentifiableObject>) ReflectionUtils.getRealClass( identifiableObject.getClass() ); if ( !uidMap.containsKey( klass ) ) uidMap.put( klass, new HashSet<>() ); if ( !codeMap.containsKey( klass ) ) codeMap.put( klass, new HashSet<>() ); if ( !StringUtils.isEmpty( identifiableObject.getUid() ) ) uidMap.get( klass ).add( identifiableObject.getUid() ); if ( !StringUtils.isEmpty( identifiableObject.getCode() ) ) codeMap.get( klass ).add( identifiableObject.getCode() ); }
public DeletedObject( IdentifiableObject identifiableObject ) { Assert.notNull( identifiableObject, "IdentifiableObject is required and can not be null." ); Assert.notNull( identifiableObject.getUid(), "IdentifiableObject.uid is required and can not be null." ); this.klass = ClassUtils.getShortName( identifiableObject.getClass() ); this.uid = identifiableObject.getUid(); this.code = !StringUtils.isEmpty( identifiableObject.getCode() ) ? identifiableObject.getCode() : null; }
public <T extends IdentifiableObject> List<String> getIdentifiers( T object ) { switch ( this ) { case UID: { return Lists.newArrayList( object.getUid() ); } case CODE: { return Lists.newArrayList( object.getCode() ); } case AUTO: { return Lists.newArrayList( object.getUid(), object.getCode() ); } } return new ArrayList<>(); }
@SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> T get( PreheatIdentifier identifier, T object ) { if ( object == null ) { return null; } T reference = null; Class<? extends IdentifiableObject> klass = (Class<? extends IdentifiableObject>) getRealClass( object.getClass() ); if ( PreheatIdentifier.UID == identifier || PreheatIdentifier.AUTO == identifier ) { reference = get( PreheatIdentifier.UID, klass, object.getUid() ); } if ( PreheatIdentifier.CODE == identifier || (reference == null && PreheatIdentifier.AUTO == identifier) ) { reference = get( PreheatIdentifier.CODE, klass, object.getCode() ); } return reference; }
/** * Equality check against typed identifiable object. This method is not * vulnerable to proxy issues, where an uninitialized object class type * fails comparison to a real class. * * @param other the identifiable object to compare this object against. * @return true if equal. */ public boolean typedEquals( IdentifiableObject other ) { if ( other == null ) { return false; } if ( getUid() != null ? !getUid().equals( other.getUid() ) : other.getUid() != null ) { return false; } if ( getCode() != null ? !getCode().equals( other.getCode() ) : other.getCode() != null ) { return false; } if ( getName() != null ? !getName().equals( other.getName() ) : other.getName() != null ) { return false; } return true; }
public static String getValue( IdentifiableObject identifiableObject, IdScheme idScheme ) { boolean isId = idScheme.is( IdentifiableProperty.ID ) || idScheme.is( IdentifiableProperty.UID ); if ( isId ) { return identifiableObject.getUid(); } else if ( idScheme.is( IdentifiableProperty.CODE ) ) { return identifiableObject.getCode(); } else if ( idScheme.is( IdentifiableProperty.NAME ) ) { return identifiableObject.getName(); } return null; }
audit.setCode( ((IdentifiableObject) target).getCode() );
audit.setKlass( klass.getName() ); audit.setUid( object.getUid() ); audit.setCode( object.getCode() ); audit.setType( AuditType.CREATE );
audit.setKlass( klass.getName() ); audit.setUid( object.getUid() ); audit.setCode( object.getCode() ); audit.setType( AuditType.DELETE );
audit.setKlass( klass.getName() ); audit.setUid( object.getUid() ); audit.setCode( object.getCode() ); audit.setType( AuditType.UPDATE );