Java Code Examples for org.apache.atlas.model.typedef.AtlasBaseTypeDef#setTypeVersion()
The following examples show how to use
org.apache.atlas.model.typedef.AtlasBaseTypeDef#setTypeVersion() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasTypeDefStoreInitializer.java From atlas with Apache License 2.0 | 6 votes |
@Override public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException { String typeName = patch.getTypeName(); AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName); PatchStatus ret; if (typeDef == null) { throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName); } if (isPatchApplicable(patch, typeDef)) { typeDef.setServiceType(patch.getServiceType()); typeDef.setTypeVersion(patch.getUpdateToVersion()); typeDefStore.updateTypesDef(AtlasTypeUtil.getTypesDef(typeDef)); ret = APPLIED; } else { LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}", patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion()); ret = SKIPPED; } return ret; }
Example 2
Source File: AtlasTypeDefStoreInitializer.java From atlas with Apache License 2.0 | 5 votes |
@Override public PatchStatus applyPatch(TypeDefPatch patch) throws AtlasBaseException { String typeName = patch.getTypeName(); AtlasBaseTypeDef typeDef = typeRegistry.getTypeDefByName(typeName); PatchStatus ret; if (typeDef == null) { throw new AtlasBaseException(AtlasErrorCode.PATCH_FOR_UNKNOWN_TYPE, patch.getAction(), typeName); } if (MapUtils.isEmpty(patch.getTypeDefOptions())) { throw new AtlasBaseException(AtlasErrorCode.PATCH_INVALID_DATA, patch.getAction(), typeName); } if (isPatchApplicable(patch, typeDef)) { if (typeDef.getOptions() == null) { typeDef.setOptions(patch.getTypeDefOptions()); } else { typeDef.getOptions().putAll(patch.getTypeDefOptions()); } typeDef.setTypeVersion(patch.getUpdateToVersion()); typeDefStore.updateTypesDef(AtlasTypeUtil.getTypesDef(typeDef)); ret = APPLIED; } else { LOG.info("patch skipped: typeName={}; applyToVersion={}; updateToVersion={}", patch.getTypeName(), patch.getApplyToVersion(), patch.getUpdateToVersion()); ret = SKIPPED; } return ret; }
Example 3
Source File: AtlasTypeDefGraphStoreV1.java From incubator-atlas with Apache License 2.0 | 5 votes |
void vertexToTypeDef(AtlasVertex vertex, AtlasBaseTypeDef typeDef) { String name = vertex.getProperty(Constants.TYPENAME_PROPERTY_KEY, String.class); String description = vertex.getProperty(Constants.TYPEDESCRIPTION_PROPERTY_KEY, String.class); String typeVersion = vertex.getProperty(Constants.TYPEVERSION_PROPERTY_KEY, String.class); String guid = vertex.getProperty(Constants.GUID_PROPERTY_KEY, String.class); Long createTime = vertex.getProperty(Constants.TIMESTAMP_PROPERTY_KEY, Long.class); Long updateTime = vertex.getProperty(Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, Long.class); Long version = vertex.getProperty(Constants.VERSION_PROPERTY_KEY, Long.class); String options = vertex.getProperty(Constants.TYPEOPTIONS_PROPERTY_KEY, String.class); typeDef.setName(name); typeDef.setDescription(description); typeDef.setTypeVersion(typeVersion); typeDef.setGuid(guid); if (createTime != null) { typeDef.setCreateTime(new Date(createTime)); } if (updateTime != null) { typeDef.setUpdateTime(new Date(updateTime)); } if (version != null) { typeDef.setVersion(version); } if (options != null) { typeDef.setOptions(AtlasType.fromJson(options, Map.class)); } }
Example 4
Source File: AtlasTypeDefGraphStoreV1.java From incubator-atlas with Apache License 2.0 | 4 votes |
AtlasVertex createTypeVertex(AtlasBaseTypeDef typeDef) { // Validate all the required checks Preconditions.checkArgument(StringUtils.isNotBlank(typeDef.getName()), "Type name can't be null/empty"); AtlasVertex ret = atlasGraph.addVertex(); if (StringUtils.isBlank(typeDef.getTypeVersion())) { typeDef.setTypeVersion("1.0"); } if (typeDef.getVersion() == null) { typeDef.setVersion(1L); } if (StringUtils.isBlank(typeDef.getGuid())) { typeDef.setGuid(UUID.randomUUID().toString()); } if (typeDef.getCreateTime() == null) { typeDef.setCreateTime(new Date()); } if (typeDef.getUpdateTime() == null) { typeDef.setUpdateTime(new Date()); } ret.setProperty(VERTEX_TYPE_PROPERTY_KEY, VERTEX_TYPE); // Mark as type vertex ret.setProperty(TYPE_CATEGORY_PROPERTY_KEY, getTypeCategory(typeDef)); ret.setProperty(Constants.TYPENAME_PROPERTY_KEY, typeDef.getName()); ret.setProperty(Constants.TYPEDESCRIPTION_PROPERTY_KEY, StringUtils.isNotBlank(typeDef.getDescription()) ? typeDef.getDescription() : typeDef.getName()); ret.setProperty(Constants.TYPEVERSION_PROPERTY_KEY, typeDef.getTypeVersion()); ret.setProperty(Constants.GUID_PROPERTY_KEY, typeDef.getGuid()); ret.setProperty(Constants.TIMESTAMP_PROPERTY_KEY, typeDef.getCreateTime().getTime()); ret.setProperty(Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, typeDef.getUpdateTime().getTime()); ret.setProperty(Constants.VERSION_PROPERTY_KEY, typeDef.getVersion()); ret.setProperty(Constants.TYPEOPTIONS_PROPERTY_KEY, AtlasType.toJson(typeDef.getOptions())); return ret; }