Closed Mirovan closed 3 years ago
When I try using default Egeria TypeDef I have same error:
EntityDetail entityDetail = new EntityDetail();
InstanceType instanceType = new InstanceType();
instanceType.setTypeDefName("SoftwareServer");
entityDetail.setType(instanceType);
List<Classification> classifications = new ArrayList<>();
Classification c = new Classification();
c.setName("ApplicationServer");
classifications.add(c);
entityDetail.setClassifications(classifications);
EntityDetail term = entityDetailService.create(entityDetail);
My entityDetailService:
public EntityDetail create(EntityDetail entityDetail) {
//get typedef
TypeDef typeDef = typeDefService.getTypeDefByName(entityDetail.getType().getTypeDefName());
String typeDefGUID = typeDef.getGUID();
EntityCreateRequest createRequest = new EntityCreateRequest();
createRequest.setEntityTypeGUID(typeDefGUID);
createRequest.setInitialStatus(InstanceStatus.ACTIVE);
createRequest.setInitialProperties(entityDetail.getProperties());
createRequest.setInitialClassifications(entityDetail.getClassifications());
EntityDetailResponse responseEntityDetail = null;
try {
//Call request
responseEntityDetail = clientConnector.callPostRESTCall(
"addEntity",
EntityDetailResponse.class,
egeriaHelper.buildURL("/entity"),
createRequest
);
} catch (RESTServerException e) {
log.warn(e.toString());
}
return Optional.ofNullable(responseEntityDetail.getEntity())
.orElseThrow(() -> new RuntimeException(String.format("Ошибка создания сущности '%s'", entityDetail.toString())));
}
Hi @Mirovan - I think the problem is that although you are creating a Classification object it is not fully initialised with core properties.
I wasn't sure quite what you meant by 'create some EntityDetail ... and map to Classification'. The normally expected behaviour would, I think, be to create an entity and then associate it with a classification. There are a couple of things that I would recommend looking at:
1) When you create an entity in the repository (using metadataCollection.addEntity) you can supply the entity type GUID and a set of initial entity properties and initial entity classifications. That would save you having to create and initialise the entity and classification objects yourself.
2) The repository content helper provides helper methods, like getSkeletonClassification, which will do a lot of initialisation for you. The helper method will set up things like the type information (which from the error message you posted is why your classification is rejected by the repository), as well as the other core properties.
3) If you need to associate a classification with an existing entity, you could use the metadataCollection's classifyEntity method.
I hope this helps. All the best, Graham
@grahamwallis thank you!
I solve it with new request for Egeria API, I call method - /servers/{serverName}/open-metadata/repository-services/users/{userId}/instances/entity/{entityGUID}/classification/{classificationName}.
But now I have to request:
If it possible, I want make only one request, when I call GraphOMRSClassificationMapper method mapClassificationToVertex - there is some error. What wrong, I can't understand (
Hi @Mirovan - Is there a reason that you cannot use either addEntity (with an initial classification) or for an existing entity, use classifyEntity?
Hi @grahamwallis ! Now my problem was solved.
I am try create some EntityDetail by my custom EntityDef and map to Classification.
There are my code:
My ClassificationDef:
If I create EntityDetail it is work perfectly, but if I set some ClassificationDef, I get this bug:
We are using Egeria 2.3. How I can solve this mistake?