Ignore:
Timestamp:
08/11/14 16:07:55 (10 years ago)
Author:
olhsha@mpi.nl
Message:

Added group service. Tested via the tomcat on loclahots (test URI and postman), old unit tests are adjusted and work well. Todo: retest on localhost tomcat, look at run-time exceptions, add new unit tests, adjust front-end

File:
1 edited

Legend:

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

    r4098 r5549  
    110110     */
    111111    private List<BaseDescription> augment(List<BaseDescription> baseDescription) {
    112         if (baseDescription.isEmpty())
     112        if (baseDescription.isEmpty()) {
    113113            return baseDescription;
     114        }
    114115        Map<String, BaseDescription> map = new HashMap<String, BaseDescription>();
    115116        List<String> idlist = new ArrayList<String>();
     
    165166     *         public)
    166167     */
    167     @Override
    168     public boolean isInRegistry(String cmdId, Number userId) {
    169         if (userId == null) {
    170             return isPublic(cmdId);
    171         } else {
    172             return isInUserSpace(cmdId, userId);
    173         }
    174     }
     168//    @Override
     169//    public boolean isAccessible(String cmdId, Number userId) {
     170//      if (userId == null) {
     171//          return this.isPublic(cmdId);
     172//      } else {
     173//          return this.isInUserSpace(cmdId, userId);
     174//      }
     175//    }
    175176
    176177    /**
     
    207208        copy.setPublic(isPublic);
    208209        copy.setUserId(toString(userId));
     210        copy.setCreatorName(description.getCreatorName());
    209211        copy = jpaComponentDao.saveAndFlush(copy);
    210212        jpaComponentDao.updateContent(copy.getId(), content);
     
    278280    }
    279281
    280     /**
    281      * Get by ComponentId / ProfileId
    282      *
    283      * @param id
    284      *            Full component id
    285      * @param userId
    286      *            Db id of user for workspace; null for public space
    287      * @return The description, if it exists; null otherwise
    288      */
    289     @Override
    290     public BaseDescription getByCmdId(String id, Number userId) {
    291         BaseDescription baseDescription = getByCmdId(id);
    292         if (baseDescription != null) {
    293             augment(baseDescription);
    294             if (userId == null) {
    295                 if (!baseDescription.isPublic())
    296                     baseDescription = null;
    297             } else {
    298                 if (baseDescription.isPublic()
    299                         || !compare(baseDescription.getUserId(), userId))
    300                     baseDescription = null;
    301             }
    302         }
    303         return baseDescription;
    304     }
    305 
     282 
    306283    /**
    307284     *
     
    352329     */
    353330    @Override
    354     public List<BaseDescription> getUserspaceComponents(Number userId) {
    355         return augment(jpaComponentDao
    356                 .findItemsForUserThatAreNotInGroups(userId.longValue(),
    357                         ComponentDescription.COMPONENT_PREFIX + "%"));
    358     }
    359 
    360     @Override
    361     public List<BaseDescription> getUserspaceProfiles(Number userId) {
    362         return augment(jpaComponentDao.findItemsForUserThatAreNotInGroups(
    363                 userId.longValue(), ProfileDescription.PROFILE_PREFIX + "%"));
    364     }
    365 
     331    public List<BaseDescription> getPrivateBaseDescriptions(Number userId, String prefix) {
     332        return augment(jpaComponentDao.findItemsForUserThatAreNotInGroups(userId.longValue(),prefix + "%"));
     333        //return augment(jpaComponentDao.findNotPublishedUserItems(userId.longValue(),prefix + "%"));
     334    }
     335
     336   
    366337    @Override
    367338    public void setDeleted(BaseDescription desc, boolean isDeleted) {
     
    399370
    400371    @Override
    401     public List<BaseDescription> getPublicComponentDescriptions() {
    402         return augment(jpaComponentDao
    403                 .findPublicItems(ComponentDescription.COMPONENT_PREFIX + "%"));
    404     }
    405 
    406     @Override
    407     public List<BaseDescription> getPublicProfileDescriptions() {
    408         return augment(jpaComponentDao
    409                 .findPublicItems(ProfileDescription.PROFILE_PREFIX + "%"));
    410     }
    411 
     372    public List<BaseDescription> getPublicBaseDescriptions(String prefix) {
     373        return augment(jpaComponentDao.findPublishedItems(prefix + "%"));
     374    }
     375
     376   
    412377    @Override
    413378    public List<String> getAllNonDeletedProfileIds() {
     
    419384        return jpaComponentDao.findNonDeletedItemIds(ComponentDescription.COMPONENT_PREFIX+"%");
    420385    }
    421 
     386   
     387    @Override
     388    public List<BaseDescription> getAllNonDeletedDescriptions() {
     389        return jpaComponentDao.findNonDeletedDescriptions();
     390    }
     391   
     392    // Olha was here
     393    @Override
     394    public List<String> getAllItemIdsInGroup(String prefix, Long groupId) {
     395        // we are ineterested only in non-published components in the group
     396        return jpaComponentDao.findAllItemIdsInGroup(false, prefix + "%", groupId);
     397    }
     398   
     399   
    422400}
Note: See TracChangeset for help on using the changeset viewer.