Changeset 5549 for ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/persistence/impl/ComponentDaoImpl.java
- Timestamp:
- 08/11/14 16:07:55 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/persistence/impl/ComponentDaoImpl.java
r4098 r5549 110 110 */ 111 111 private List<BaseDescription> augment(List<BaseDescription> baseDescription) { 112 if (baseDescription.isEmpty()) 112 if (baseDescription.isEmpty()) { 113 113 return baseDescription; 114 } 114 115 Map<String, BaseDescription> map = new HashMap<String, BaseDescription>(); 115 116 List<String> idlist = new ArrayList<String>(); … … 165 166 * public) 166 167 */ 167 @Override168 public boolean isInRegistry(String cmdId, Number userId) {169 if (userId == null) {170 returnisPublic(cmdId);171 } else {172 returnisInUserSpace(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 // } 175 176 176 177 /** … … 207 208 copy.setPublic(isPublic); 208 209 copy.setUserId(toString(userId)); 210 copy.setCreatorName(description.getCreatorName()); 209 211 copy = jpaComponentDao.saveAndFlush(copy); 210 212 jpaComponentDao.updateContent(copy.getId(), content); … … 278 280 } 279 281 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 306 283 /** 307 284 * … … 352 329 */ 353 330 @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 366 337 @Override 367 338 public void setDeleted(BaseDescription desc, boolean isDeleted) { … … 399 370 400 371 @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 412 377 @Override 413 378 public List<String> getAllNonDeletedProfileIds() { … … 419 384 return jpaComponentDao.findNonDeletedItemIds(ComponentDescription.COMPONENT_PREFIX+"%"); 420 385 } 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 422 400 }
Note: See TracChangeset
for help on using the changeset viewer.