@Override public void delete( IdentifiableObject object ) { delete( object, currentUserService.getCurrentUser() ); }
@Override @SuppressWarnings( "unchecked" ) public <T extends DimensionalObject> List<T> getDataDimensions( Class<T> clazz ) { GenericDimensionalObjectStore<DimensionalObject> store = getDimensionalObjectStore( clazz ); if ( store == null ) { return new ArrayList<>(); } return (List<T>) store.getByDataDimension( true ); }
@Override public <T extends IdentifiableObject> List<T> filter( Class<T> clazz, String query ) { Set<T> uniqueObjects = new HashSet<>(); T uidObject = get( clazz, query ); if ( uidObject != null ) { uniqueObjects.add( uidObject ); } T codeObject = getByCode( clazz, query ); if ( codeObject != null ) { uniqueObjects.add( codeObject ); } uniqueObjects.addAll( getLikeName( clazz, query ) ); List<T> objects = new ArrayList<>( uniqueObjects ); Collections.sort( objects ); return objects; }
@Override public void update( IdentifiableObject object, User user ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( object.getClass() ); if ( store != null ) { store.update( object, user ); } }
public <T extends IdentifiableObject> T getObject( Class<T> clazz, IdScheme idScheme, String value ) IdentifiableObjectStore<T> store = (IdentifiableObjectStore<T>) getIdentifiableObjectStore( clazz ); Attribute attribute = get( Attribute.class, idScheme.getAttribute() ); return store.getByUniqueAttributeValue( attribute, value );
@Override public <T extends IdentifiableObject> boolean exists( Class<T> clazz, String uid ) { return get( clazz, uid ) != null; }
@Override public <T extends IdentifiableObject> Map<String, T> getIdMap( Class<T> clazz, IdentifiableProperty property ) { return getIdMap( clazz, IdScheme.from( property ) ); }
@Override public <T extends IdentifiableObject> Map<String, T> getIdMapNoAcl( Class<T> clazz, IdentifiableProperty property ) { return getIdMapNoAcl( clazz, IdScheme.from( property ) ); }
@Override public Map<Class<? extends IdentifiableObject>, IdentifiableObject> getDefaults() { return new ImmutableMap.Builder<Class<? extends IdentifiableObject>, IdentifiableObject>() .put( Category.class, DEFAULT_OBJECT_CACHE.get( Category.class, key -> getByName( Category.class, "default" ) ) ) .put( CategoryCombo.class, DEFAULT_OBJECT_CACHE.get( CategoryCombo.class, key -> getByName( CategoryCombo.class, "default" ) ) ) .put( CategoryOption.class, DEFAULT_OBJECT_CACHE.get( CategoryOption.class, key -> getByName( CategoryOption.class, "default" ) ) ) .put( CategoryOptionCombo.class, DEFAULT_OBJECT_CACHE.get( CategoryOptionCombo.class, key -> getByName( CategoryOptionCombo.class, "default" ) ) ) .build(); }
@Override public boolean isDefault( IdentifiableObject object ) { Map<Class<? extends IdentifiableObject>, IdentifiableObject> defaults = getDefaults(); if ( object == null ) { return false; } Class<?> realClass = getRealClass( object.getClass() ); if ( !defaults.containsKey( realClass ) ) { return false; } IdentifiableObject defaultObject = defaults.get( realClass ); return defaultObject != null && defaultObject.getUid().equals( object.getUid() ); }
@Override @SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> T getByCode( Class<T> clazz, String code ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz ); if ( store == null ) { return null; } return (T) store.getByCode( code ); }
@Override @SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> T get( Collection<Class<? extends IdentifiableObject>> classes, String uid ) { for ( Class<? extends IdentifiableObject> clazz : classes ) { T object = (T) get( clazz, uid ); if ( object != null ) { return object; } } return null; }
@Override public <T extends IdentifiableObject> int getCount( Class<T> clazz ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz ); if ( store != null ) { return store.getCount(); } return 0; }
@Override @SuppressWarnings( "unchecked" ) public <T extends DimensionalObject> List<T> getDataDimensionsNoAcl( Class<T> clazz ) { GenericDimensionalObjectStore<DimensionalObject> store = getDimensionalObjectStore( clazz ); if ( store == null ) { return new ArrayList<>(); } return (List<T>) store.getByDataDimensionNoAcl( true ); }
@Override @SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> List<T> getObjects( Class<T> clazz, Collection<Integer> identifiers ) { IdentifiableObjectStore<T> store = (IdentifiableObjectStore<T>) getIdentifiableObjectStore( clazz ); if ( store == null ) { return new ArrayList<>(); } return store.getById( identifiers ); }
@Override public <T extends IdentifiableObject> boolean isAttributeValueUnique( Class<? extends IdentifiableObject> klass, T object, Attribute attribute, String value ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( klass ); return store != null && store.isAttributeValueUnique( object, attribute, value ); }
@Override public void delete( IdentifiableObject object, User user ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( object.getClass() ); if ( store != null ) { store.delete( object, user ); } }
@Override @SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> T getByName( Class<T> clazz, String name ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz ); if ( store == null ) { return null; } return (T) store.getByName( name ); }
@Override @SuppressWarnings( "unchecked" ) public <T extends IdentifiableObject> List<T> getDataWriteAll( Class<T> clazz ) { IdentifiableObjectStore<IdentifiableObject> store = getIdentifiableObjectStore( clazz ); if ( store == null ) { return new ArrayList<>(); } return (List<T>) store.getDataWriteAll(); }