use of com.icthh.xm.ms.entity.domain.spec.TypeSpec in project xm-ms-entity by xm-online.
the class XmEntityGeneratorServiceIntTest method generateXmEntityWithTagsTest.
@Test
@SneakyThrows
public void generateXmEntityWithTagsTest() {
XmEntity generatedEntity = xmEntityGeneratorService.generateXmEntity(ENTITY_TYPE_WITH_TAGS_AND_LOCATIONS_KEY);
log.info(new ObjectMapper().writeValueAsString(generatedEntity));
Set<Tag> tags = generatedEntity.getTags();
assertFalse("No tags generated", isEmpty(tags));
TypeSpec specType = xmEntitySpecService.findTypeByKey("TYPE1.SUBTYPE1");
List<TagSpec> tagsSpecs = specType.getTags();
Set<String> specTagsKeys = tagsSpecs.stream().map(TagSpec::getKey).collect(toSet());
Set<String> tagsKeys = tags.stream().map(Tag::getTypeKey).collect(toSet());
assertTrue("Tag type not from tag specification", specTagsKeys.containsAll(tagsKeys));
for (val tag : tags) {
assertFalse("Name of tag is empty", isBlank(tag.getName()));
}
}
use of com.icthh.xm.ms.entity.domain.spec.TypeSpec in project xm-ms-entity by xm-online.
the class XmEntitySpecServiceUnitTest method testFindTypeByKey.
@Test
public void testFindTypeByKey() {
TypeSpec type = xmEntitySpecService.findTypeByKey(KEY1);
assertNotNull(type);
assertEquals(KEY1, type.getKey());
type = xmEntitySpecService.findTypeByKey(KEY3);
assertNotNull(type);
assertEquals(KEY3, type.getKey());
type = xmEntitySpecService.findTypeByKey(KEY4);
assertNull(type);
}
use of com.icthh.xm.ms.entity.domain.spec.TypeSpec in project xm-ms-entity by xm-online.
the class XmEntitySpecResource method getTypeSpec.
/**
* GET /xm-entity-specs/:key : get the "key" typeSpec.
*
* @param key the key of the typeSpec to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the typeSpec, or with status 404 (Not Found)
*/
@GetMapping("/xm-entity-specs/{key}")
@Timed
@PostAuthorize("hasPermission({'returnObject': returnObject.body}, 'XMENTITY_SPEC.GET_LIST.ITEM')")
public ResponseEntity<TypeSpec> getTypeSpec(@PathVariable String key) {
log.debug("REST request to get TypeSpec : {}", key);
TypeSpec typeSpec = xmEntitySpecService.findTypeByKey(key);
return RespContentUtil.wrapOrNotFound(Optional.ofNullable(typeSpec));
}
use of com.icthh.xm.ms.entity.domain.spec.TypeSpec in project xm-ms-entity by xm-online.
the class XmEntityServiceImpl method deleteXmEntity.
private void deleteXmEntity(XmEntity xmEntity) {
TypeSpec spec = xmEntitySpecService.findTypeByKey(xmEntity.getTypeKey());
Map<String, String> linkSpec = ofNullable(spec).map(TypeSpec::getLinks).orElse(emptyList()).stream().collect(toMap(LinkSpec::getKey, LinkSpec::getBuilderType));
Iterator<Link> iterator = nullSafe(xmEntity.getTargets()).iterator();
while (iterator.hasNext()) {
Link target = iterator.next();
iterator.remove();
linkService.delete(target.getId());
if (NEW_BUILDER_TYPE.equalsIgnoreCase(linkSpec.get(target.getTypeKey()))) {
deleteNewLink(target);
} else if (!SEARCH_BUILDER_TYPE.equals(linkSpec.get(target.getTypeKey()))) {
log.warn("Unknown link builder type |{}| for link type {}", linkSpec.get(target.getTypeKey()), target.getTypeKey());
}
}
xmEntityRepository.delete(xmEntity.getId());
xmEntitySearchRepository.delete(xmEntity.getId());
}
Aggregations