All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.metadata.persistence.spi.MetadataPersistenceSpi Maven / Gradle / Ivy

The newest version!
/***********************************************************************************************************************
 *
 * blueMarine Metadata - open source media workflow
 * Copyright (C) 2007-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
 *
 ***********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 ***********************************************************************************************************************
 *
 * WWW: http://bluemarine.tidalwave.it
 * SCM: https://kenai.com/hg/bluemarine~metadata-src
 *
 **********************************************************************************************************************/
package it.tidalwave.metadata.persistence.spi;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import java.util.List;
import org.openide.util.Lookup;
import org.openide.loaders.DataObject;
import it.tidalwave.metadata.persistence.MetadataComposite;
import it.tidalwave.metadata.persistence.MetadataProperty;
import it.tidalwave.metadata.persistence.MetadataPersistence;
import it.tidalwave.metadata.persistence.query.Criterion;

/*******************************************************************************
 *
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 ******************************************************************************/
public interface MetadataPersistenceSpi extends MetadataPersistence
  {
    /***************************************************************************
     *
     * Finds all the {@link DataObject}s that satisfy a given criterion.
     * 
     * @param  criterion    the criterion
     * @return              the objects
     * 
     **************************************************************************/
    @Nonnull 
    public List findDataObjects (@Nonnull Criterion criterion)
      throws UnknownPropertyException;

    /***************************************************************************
     *
     * Returns the count of all {@link DataObject}s bound to the given criterion.
     * 
     * @param  criterion  the criterion
     * @return            the bind count  
     * 
     **************************************************************************/
    @Nonnegative
    public int findDataObjectCount (@Nonnull Criterion criterion)
      throws UnknownPropertyException;

    /***************************************************************************
     *
     * Returns the list of all {@link MetadataProperty} items beloging to a 
     * given parent.
     * 
     * @param  parent  the parent
     * @return         the list of properties
     * 
     **************************************************************************/
    @Nonnull 
    public List findProperties (@Nonnull MetadataComposite parent);
    
    /***************************************************************************
     *
     * Returns a list of all the stored values for a given 
     * {@link MetadataProperty}.
     * 
     * @param  property  the property
     * @return           the list of values
     * 
     **************************************************************************/
    @Nonnull 
    public  List findValues (@Nonnull MetadataProperty property);
    
    /***************************************************************************
     *
     * TODO: could be removed? Make BeanAccessors registrable by META-INF?
     * 
     **************************************************************************/
    public  void register (@Nonnull Class beanClass, @Nonnull BeanAccessor beanAccessor);
    
    /***************************************************************************
     *
     **************************************************************************/
    @CheckForNull
    public Class findBeanClassByPropertySetName (@Nonnull String groupName);
    
    /***************************************************************************
     *
     **************************************************************************/
    @CheckForNull
    public String findPropertySetNameByBeanClass (@Nonnull Class beanClass);
    
    /***************************************************************************
     *
     **************************************************************************/
    @CheckForNull
    public BeanAccessor findAccessorByClass (@Nonnull Class beanClass);
    
    /***************************************************************************
     *
     * The Service Locator for MetadataPersistence.
     * 
     **************************************************************************/
    public static final class Locator
      {
        private Locator()
          {
          }
        
        @Nonnull 
        public static MetadataPersistenceSpi findPersistenceSpi()
          {
            final MetadataPersistenceSpi spi = Lookup.getDefault().lookup(MetadataPersistenceSpi.class);
            
            if (spi == null)
              {
                throw new RuntimeException("MetadataPersistenceSpi not found");
              }
            
            return spi;
          }
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy