use of com.icthh.xm.ms.entity.domain.spec.LinkSpec in project xm-ms-entity by xm-online.
the class XmEntitySpecService method getAllKeys.
/**
* Transforms all XmEntity Specification keys into the thin structure based
* in maps and sets.
*
* @return thin structure based in maps and sets
*/
@IgnoreLogginAspect
public Map<String, Map<String, Set<String>>> getAllKeys() {
Map<String, Map<String, Set<String>>> result = Maps.newHashMap();
for (TypeSpec typeSpec : findAllTypes()) {
Map<String, Set<String>> subKeys = Maps.newHashMap();
getKeys(subKeys, AttachmentSpec.class, typeSpec.getAttachments(), AttachmentSpec::getKey);
getKeys(subKeys, CalendarSpec.class, typeSpec.getCalendars(), CalendarSpec::getKey);
getKeys(subKeys, LinkSpec.class, typeSpec.getLinks(), LinkSpec::getKey);
getKeys(subKeys, LocationSpec.class, typeSpec.getLocations(), LocationSpec::getKey);
getKeys(subKeys, RatingSpec.class, typeSpec.getRatings(), RatingSpec::getKey);
getKeys(subKeys, StateSpec.class, typeSpec.getStates(), StateSpec::getKey);
getKeys(subKeys, TagSpec.class, typeSpec.getTags(), TagSpec::getKey);
result.put(typeSpec.getKey(), subKeys);
}
return result;
}
use of com.icthh.xm.ms.entity.domain.spec.LinkSpec in project xm-ms-entity by xm-online.
the class XmEntityServiceImpl method searchXmEntitiesToLink.
@LogicExtensionPoint("SearchXmEntitiesToLink")
@Override
@Transactional(readOnly = true)
@FindWithPermission("XMENTITY.SEARCH")
@PrivilegeDescription("Privilege to search for the xmEntity corresponding to the query")
public Page<XmEntity> searchXmEntitiesToLink(IdOrKey idOrKey, String entityTypeKey, String linkTypeKey, String query, Pageable pageable, String privilegeKey) {
LinkSpec linkSpec = xmEntitySpecService.getLinkSpec(entityTypeKey, linkTypeKey).orElseThrow(() -> new IllegalArgumentException("Invalid entity typeKey ot link typeKey"));
if (!TRUE.equals(linkSpec.getIsUnique())) {
return self.search(query, pageable, privilegeKey);
}
Long id;
if (idOrKey.isId()) {
id = idOrKey.getId();
} else {
id = getXmEntityIdKeyTypeKey(idOrKey).getId();
}
List<LinkProjection> links = linkService.findLinkProjectionsBySourceIdAndTypeKey(id, linkTypeKey);
Set<Long> ids = links.stream().map(LinkProjection::getTarget).map(XmEntityId::getId).collect(toSet());
ids = new HashSet<>(ids);
ids.add(id);
return xmEntityPermittedSearchRepository.searchWithIdNotIn(query, ids, linkSpec.getTypeKey(), pageable, privilegeKey);
}
Aggregations