use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.
the class AtlasEntityChangeNotifier method onClassificationAddedToEntity.
public void onClassificationAddedToEntity(AtlasEntity entity, List<AtlasClassification> addedClassifications) throws AtlasBaseException {
if (isV2EntityNotificationEnabled()) {
doFullTextMapping(entity.getGuid());
for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
listener.onClassificationsAdded(entity, addedClassifications);
}
} else {
updateFullTextMapping(entity.getGuid(), addedClassifications);
Referenceable entityRef = toReferenceable(entity.getGuid());
List<Struct> traits = toStruct(addedClassifications);
if (entity == null || CollectionUtils.isEmpty(traits)) {
return;
}
for (EntityChangeListener listener : entityChangeListeners) {
try {
listener.onTraitsAdded(entityRef, traits);
} catch (AtlasException e) {
throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitAdd");
}
}
}
}
use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.
the class AtlasEntityChangeNotifier method onClassificationUpdatedToEntity.
public void onClassificationUpdatedToEntity(AtlasEntity entity, List<AtlasClassification> updatedClassifications) throws AtlasBaseException {
if (isV2EntityNotificationEnabled()) {
doFullTextMapping(entity.getGuid());
for (EntityChangeListenerV2 listener : entityChangeListenersV2) {
listener.onClassificationsUpdated(entity, updatedClassifications);
}
} else {
doFullTextMapping(entity.getGuid());
Referenceable entityRef = toReferenceable(entity.getGuid());
List<Struct> traits = toStruct(updatedClassifications);
if (entityRef == null || CollectionUtils.isEmpty(traits)) {
return;
}
for (EntityChangeListener listener : entityChangeListeners) {
try {
listener.onTraitsUpdated(entityRef, traits);
} catch (AtlasException e) {
throw new AtlasBaseException(AtlasErrorCode.NOTIFICATION_FAILED, e, getListenerName(listener), "TraitUpdate");
}
}
}
}
use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.
the class AtlasStructFormatConverter method fromV2ToV1.
@Override
public Object fromV2ToV1(Object v2Obj, AtlasType type, ConverterContext converterContext) throws AtlasBaseException {
Struct ret = null;
if (v2Obj != null) {
AtlasStructType structType = (AtlasStructType) type;
if (v2Obj instanceof Map) {
final Map v2Map = (Map) v2Obj;
final Map v2Attribs;
if (v2Map.containsKey(ATTRIBUTES_PROPERTY_KEY)) {
v2Attribs = (Map) v2Map.get(ATTRIBUTES_PROPERTY_KEY);
} else {
v2Attribs = v2Map;
}
if (MapUtils.isNotEmpty(v2Attribs)) {
ret = new Struct(type.getTypeName(), fromV2ToV1(structType, v2Attribs, converterContext));
} else {
ret = new Struct(type.getTypeName());
}
} else if (v2Obj instanceof AtlasStruct) {
AtlasStruct struct = (AtlasStruct) v2Obj;
ret = new Struct(type.getTypeName(), fromV2ToV1(structType, struct.getAttributes(), converterContext));
} else {
throw new AtlasBaseException(AtlasErrorCode.UNEXPECTED_TYPE, "Map or AtlasStruct", v2Obj.getClass().getCanonicalName());
}
}
return ret;
}
use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.
the class EntityAuditListener method onTraitsUpdated.
@Override
public void onTraitsUpdated(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
if (traits != null) {
for (Struct trait : traits) {
EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_UPDATE, "Updated trait: " + AtlasType.toV1Json(trait));
auditRepository.putEventsV1(event);
}
}
}
use of org.apache.atlas.v1.model.instance.Struct in project atlas by apache.
the class EntityAuditListener method onTraitsAdded.
@Override
public void onTraitsAdded(Referenceable entity, Collection<? extends Struct> traits) throws AtlasException {
if (traits != null) {
for (Struct trait : traits) {
EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_ADD, "Added trait: " + AtlasType.toV1Json(trait));
auditRepository.putEventsV1(event);
}
}
}
Aggregations