use of org.apache.atlas.typesystem.persistence.StructInstance in project incubator-atlas by apache.
the class ClassType method createInstanceWithTraits.
public ITypedReferenceableInstance createInstanceWithTraits(Id id, AtlasSystemAttributes systemAttributes, Referenceable r, String... traitNames) throws AtlasException {
ImmutableMap.Builder<String, ITypedStruct> b = new ImmutableBiMap.Builder<>();
if (traitNames != null) {
for (String t : traitNames) {
TraitType tType = typeSystem.getDataType(TraitType.class, t);
IStruct iTraitObject = r == null ? null : r.getTrait(t);
ITypedStruct trait = iTraitObject == null ? tType.createInstance() : tType.convert(iTraitObject, Multiplicity.REQUIRED);
b.put(t, trait);
}
}
return new ReferenceableInstance(id == null ? new Id(getName()) : id, getName(), systemAttributes, fieldMapping, new boolean[fieldMapping.fields.size()], new boolean[fieldMapping.fields.size()], fieldMapping.numBools == 0 ? null : new boolean[fieldMapping.numBools], fieldMapping.numBytes == 0 ? null : new byte[fieldMapping.numBytes], fieldMapping.numShorts == 0 ? null : new short[fieldMapping.numShorts], fieldMapping.numInts == 0 ? null : new int[fieldMapping.numInts], fieldMapping.numLongs == 0 ? null : new long[fieldMapping.numLongs], fieldMapping.numFloats == 0 ? null : new float[fieldMapping.numFloats], fieldMapping.numDoubles == 0 ? null : new double[fieldMapping.numDoubles], fieldMapping.numBigDecimals == 0 ? null : new BigDecimal[fieldMapping.numBigDecimals], fieldMapping.numBigInts == 0 ? null : new BigInteger[fieldMapping.numBigInts], fieldMapping.numDates == 0 ? null : new Date[fieldMapping.numDates], fieldMapping.numStrings == 0 ? null : new String[fieldMapping.numStrings], fieldMapping.numArrays == 0 ? null : new ImmutableList[fieldMapping.numArrays], fieldMapping.numMaps == 0 ? null : new ImmutableMap[fieldMapping.numMaps], fieldMapping.numStructs == 0 ? null : new StructInstance[fieldMapping.numStructs], fieldMapping.numReferenceables == 0 ? null : new ReferenceableInstance[fieldMapping.numReferenceables], fieldMapping.numReferenceables == 0 ? null : new Id[fieldMapping.numReferenceables], b.build());
}
use of org.apache.atlas.typesystem.persistence.StructInstance in project incubator-atlas by apache.
the class StructStore method load.
@Override
protected void load(StructInstance instance, int colPos, int pos) throws RepositoryException {
StructInstance s = (StructInstance) structType.createInstance();
instance.structs[colPos] = s;
for (Map.Entry<AttributeInfo, IAttributeStore> e : attrStores.entrySet()) {
IAttributeStore attributeStore = e.getValue();
attributeStore.load(pos, structType, s);
}
}
use of org.apache.atlas.typesystem.persistence.StructInstance in project incubator-atlas by apache.
the class AtlasObjectIdConverter method hasAnyAssignedAttribute.
private boolean hasAnyAssignedAttribute(IReferenceableInstance rInstance) {
boolean ret = false;
if (rInstance instanceof StructInstance) {
StructInstance sInstance = (StructInstance) rInstance;
Map<String, Object> attributes = null;
try {
attributes = sInstance.getValuesMap();
} catch (AtlasException e) {
// ignore
}
if (MapUtils.isNotEmpty(attributes)) {
for (String attrName : attributes.keySet()) {
try {
if (sInstance.isValueSet(attrName)) {
ret = true;
break;
}
} catch (AtlasException e) {
// ignore
}
}
}
} else if (rInstance instanceof Referenceable) {
Referenceable referenceable = (Referenceable) rInstance;
ret = MapUtils.isNotEmpty(referenceable.getValuesMap());
}
return ret;
}
use of org.apache.atlas.typesystem.persistence.StructInstance in project incubator-atlas by apache.
the class TraitStore method store.
void store(ReferenceableInstance i) throws RepositoryException {
int pos = idPosMap.get(i.getId());
StructInstance s = (StructInstance) i.getTrait(hierarchicalType.getName());
super.storeFields(pos, s);
classNameStore.set(pos, i.getTypeName());
}
use of org.apache.atlas.typesystem.persistence.StructInstance in project incubator-atlas by apache.
the class TraitStore method load.
void load(ReferenceableInstance i) throws RepositoryException {
int pos = idPosMap.get(i.getId());
StructInstance s = (StructInstance) i.getTrait(hierarchicalType.getName());
super.loadFields(pos, s);
}
Aggregations