Changeset 1604


Ignore:
Timestamp:
10/31/11 12:55:36 (13 years ago)
Author:
twagoo
Message:

Added parameter 'mdEditor' to REST call /registry/profiles which causes only selected profiles are shown. Implemented programmatic filtering on this, could be done on database which would be more efficient.

Location:
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java

    r1378 r1604  
    3131     */
    3232    List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException;
     33
     34    /**
     35     *
     36     * @return List of profile descriptions ordered by name ascending, only the ones marked for showing in metadata editor
     37     * @throws ComponentRegistryException
     38     */
     39    List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException;
    3340
    3441    ProfileDescription getProfileDescription(String id) throws ComponentRegistryException;
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/ComponentRegistryImplBase.java

    r1364 r1604  
    5454        }
    5555        return result;
     56    }
     57
     58    /**
     59     *
     60     * @return List of profile descriptions ordered by name ascending, only the ones marked for showing in metadata editor
     61     * @throws ComponentRegistryException
     62     */
     63    @Override
     64    public List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException {
     65        // TODO: Below can also be done by accepting and passing a parameter in the ProfileDescriptionDao, should have better performance
     66
     67        // Get all profile descriptions
     68        List<ProfileDescription> descriptionsCollection = getProfileDescriptions();
     69        // Filter out ones that do should not be shown for metadata editor
     70        ArrayList<ProfileDescription> descriptions = new ArrayList<ProfileDescription>(descriptionsCollection.size());
     71        for (ProfileDescription profile : descriptionsCollection) {
     72            if (((ProfileDescription) profile).isShowInEditor()) {
     73                descriptions.add((ProfileDescription) profile);
     74            }
     75        }
     76        // Return filtered list
     77        return descriptions;
    5678    }
    5779
     
    122144        return result.toString();
    123145    }
    124 
    125146}
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java

    r1465 r1604  
    9191        }
    9292    }
    93 
     93   
    9494    @Override
    9595    public ProfileDescription getProfileDescription(String id) throws ComponentRegistryException {
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ProfileDescriptionDao.java

    r1602 r1604  
    55import java.sql.ResultSet;
    66import java.sql.SQLException;
    7 import java.util.ArrayList;
    8 import java.util.Collection;
    97import java.util.Collections;
    108import java.util.List;
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r1562 r1604  
    6464    public static final String DOMAIN_FORM_FIELD = "domainName";
    6565    public static final String USERSPACE_PARAM = "userspace";
     66    public static final String METADATA_EDITOR_PARAM = "mdEditor";
    6667    @Inject(value = "componentRegistryFactory")
    6768    private ComponentRegistryFactory componentRegistryFactory;
     
    107108    @Path("/profiles")
    108109    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    109     public List<ProfileDescription> getRegisteredProfiles(@QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) throws ComponentRegistryException {
     110    public List<ProfileDescription> getRegisteredProfiles(@QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace,
     111            @QueryParam(METADATA_EDITOR_PARAM) @DefaultValue("false") boolean metadataEditor) throws ComponentRegistryException {
    110112        long start = System.currentTimeMillis();
    111         List<ProfileDescription> profiles = getRegistry(userspace).getProfileDescriptions();
     113       
     114        List<ProfileDescription> profiles;
     115        if (metadataEditor) {
     116            profiles = getRegistry(userspace).getProfileDescriptionsForMetadaEditor();
     117        } else {
     118            profiles = getRegistry(userspace).getProfileDescriptions();
     119        }
     120       
    112121        LOG.info("Releasing " + profiles.size() + " registered profiles into the world (" + (System.currentTimeMillis() - start)
    113122                + " millisecs)");
     
    211220            List<ComponentDescription> components = registry.getUsageInComponents(componentId);
    212221            List<ProfileDescription> profiles = registry.getUsageInProfiles(componentId);
    213            
     222
    214223            LOG.info("Found " + components.size() + " components and " + profiles.size() + " profiles that use component " + componentId
    215224                    + " (" + (System.currentTimeMillis() - start) + " millisecs)");
    216            
     225
    217226            List<AbstractDescription> usages = new ArrayList<AbstractDescription>(components.size() + profiles.size());
    218227            usages.addAll(components);
     
    225234        }
    226235    }
    227    
     236
    228237    /**
    229238     *
Note: See TracChangeset for help on using the changeset viewer.