Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
de0bf1db
Commit
de0bf1db
authored
Jul 14, 2016
by
Shwetha GS
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-986 Ability to differentiate business catalog terms from traits…
ATLAS-986 Ability to differentiate business catalog terms from traits (sumasai,svimal2106 via shwethags)
parent
34f67ae0
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
160 additions
and
22 deletions
+160
-22
HiveHookIT.java
.../src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
+2
-2
pom.xml
catalog/pom.xml
+7
-0
AtlasTypeSystem.java
...c/main/java/org/apache/atlas/catalog/AtlasTypeSystem.java
+1
-1
DefaultTypeSystem.java
...main/java/org/apache/atlas/catalog/DefaultTypeSystem.java
+57
-6
TaxonomyResourceProvider.java
...va/org/apache/atlas/catalog/TaxonomyResourceProvider.java
+9
-0
TaxonomyResourceDefinition.java
.../atlas/catalog/definition/TaxonomyResourceDefinition.java
+3
-0
TaxonomyResourceProviderTest.java
...rg/apache/atlas/catalog/TaxonomyResourceProviderTest.java
+2
-2
TaxonomyResourceDefinitionTest.java
...as/catalog/definition/TaxonomyResourceDefinitionTest.java
+1
-1
AtlasConstants.java
common/src/main/java/org/apache/atlas/AtlasConstants.java
+1
-0
pom.xml
pom.xml
+8
-0
release-log.txt
release-log.txt
+1
-0
pom.xml
repository/pom.xml
+7
-6
DefaultMetadataService.java
...ava/org/apache/atlas/services/DefaultMetadataService.java
+10
-1
TestUtils.java
repository/src/test/java/org/apache/atlas/TestUtils.java
+17
-0
DefaultMetadataServiceTest.java
.../org/apache/atlas/service/DefaultMetadataServiceTest.java
+7
-0
MetadataService.java
.../main/java/org/apache/atlas/services/MetadataService.java
+8
-0
EntityService.java
...in/java/org/apache/atlas/web/resources/EntityService.java
+2
-1
TaxonomyService.java
.../java/org/apache/atlas/web/resources/TaxonomyService.java
+2
-1
TaxonomyServiceTest.java
...a/org/apache/atlas/web/resources/TaxonomyServiceTest.java
+15
-1
No files found.
addons/hive-bridge/src/test/java/org/apache/atlas/hive/hook/HiveHookIT.java
View file @
de0bf1db
...
...
@@ -395,7 +395,7 @@ public class HiveHookIT {
runCommand
(
drpquery
);
assertTableIsNotRegistered
(
DEFAULT_DB
,
ctasTableName
);
//Fix after ATLAS-876
//
TODO :
Fix after ATLAS-876
runCommand
(
query
);
assertTableIsRegistered
(
DEFAULT_DB
,
ctasTableName
);
String
process2Id
=
assertProcessIsRegistered
(
hiveEventContext
,
inputs
,
outputs
);
...
...
@@ -760,7 +760,7 @@ public class HiveHookIT {
assertTableIsRegistered
(
DEFAULT_DB
,
tableName
);
assertTableIsRegistered
(
DEFAULT_DB
,
insertTableName
);
//TODO -
updat
e
//TODO -
Add update test cas
e
}
private
String
random
()
{
...
...
catalog/pom.xml
View file @
de0bf1db
...
...
@@ -39,6 +39,13 @@
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-repository
</artifactId>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-typesystem
</artifactId>
</dependency>
...
...
catalog/src/main/java/org/apache/atlas/catalog/AtlasTypeSystem.java
View file @
de0bf1db
...
...
@@ -51,7 +51,7 @@ public interface AtlasTypeSystem {
*
* @throws ResourceAlreadyExistsException if type already exists
*/
void
createEntity
(
ResourceDefinition
definition
,
Request
request
)
String
createEntity
(
ResourceDefinition
definition
,
Request
request
)
throws
ResourceAlreadyExistsException
;
/**
...
...
catalog/src/main/java/org/apache/atlas/catalog/DefaultTypeSystem.java
View file @
de0bf1db
...
...
@@ -18,24 +18,38 @@
package
org
.
apache
.
atlas
.
catalog
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.catalog.definition.ResourceDefinition
;
import
org.apache.atlas.catalog.exception.CatalogRuntimeException
;
import
org.apache.atlas.catalog.exception.ResourceAlreadyExistsException
;
import
org.apache.atlas.catalog.exception.ResourceNotFoundException
;
import
org.apache.atlas.classification.InterfaceAudience
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.Struct
;
import
org.apache.atlas.typesystem.TypesDef
;
import
org.apache.atlas.typesystem.exception.EntityExistsException
;
import
org.apache.atlas.typesystem.exception.EntityNotFoundException
;
import
org.apache.atlas.typesystem.exception.TraitNotFoundException
;
import
org.apache.atlas.typesystem.exception.TypeExistsException
;
import
org.apache.atlas.typesystem.exception.TypeNotFoundException
;
import
org.apache.atlas.typesystem.json.TypesSerialization
;
import
org.apache.atlas.typesystem.types.*
;
import
org.apache.atlas.typesystem.types.AttributeDefinition
;
import
org.apache.atlas.typesystem.types.ClassType
;
import
org.apache.atlas.typesystem.types.DataTypes
;
import
org.apache.atlas.typesystem.types.EnumTypeDefinition
;
import
org.apache.atlas.typesystem.types.HierarchicalType
;
import
org.apache.atlas.typesystem.types.HierarchicalTypeDefinition
;
import
org.apache.atlas.typesystem.types.StructTypeDefinition
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -49,12 +63,36 @@ public class DefaultTypeSystem implements AtlasTypeSystem {
*
* @param metadataService atlas metadata service
*/
public
DefaultTypeSystem
(
MetadataService
metadataService
)
{
public
DefaultTypeSystem
(
MetadataService
metadataService
)
throws
AtlasException
{
this
.
metadataService
=
metadataService
;
//Create namespace
createSuperTypes
();
}
@InterfaceAudience
.
Private
private
void
createSuperTypes
()
throws
AtlasException
{
HierarchicalTypeDefinition
<
TraitType
>
termType
=
TypesUtil
.
createTraitTypeDef
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
,
ImmutableSet
.<
String
>
of
(),
TypesUtil
.
createOptionalAttrDef
(
TaxonomyResourceProvider
.
NAMESPACE_ATTRIBUTE_NAME
,
DataTypes
.
STRING_TYPE
));
createTraitType
(
termType
);
}
private
void
createTraitType
(
HierarchicalTypeDefinition
<
TraitType
>
type
)
throws
AtlasException
{
try
{
metadataService
.
getTypeDefinition
(
type
.
typeName
);
}
catch
(
TypeNotFoundException
tne
)
{
//Type not found . Create
TypesDef
typesDef
=
TypesUtil
.
getTypesDef
(
ImmutableList
.<
EnumTypeDefinition
>
of
(),
ImmutableList
.<
StructTypeDefinition
>
of
(),
ImmutableList
.<
HierarchicalTypeDefinition
<
TraitType
>>
of
(
type
),
ImmutableList
.<
HierarchicalTypeDefinition
<
ClassType
>>
of
());
metadataService
.
createType
(
TypesSerialization
.
toJson
(
typesDef
));
}
}
@Override
public
void
createEntity
(
ResourceDefinition
definition
,
Request
request
)
throws
ResourceAlreadyExistsException
{
public
String
createEntity
(
ResourceDefinition
definition
,
Request
request
)
throws
ResourceAlreadyExistsException
{
String
typeName
=
definition
.
getTypeName
();
try
{
createClassType
(
definition
,
typeName
,
typeName
+
" Definition"
);
...
...
@@ -63,8 +101,12 @@ public class DefaultTypeSystem implements AtlasTypeSystem {
}
try
{
Referenceable
entity
=
new
Referenceable
(
typeName
,
request
.
getQueryProperties
());
//add Taxonomy Namespace
entity
.
set
(
TaxonomyResourceProvider
.
NAMESPACE_ATTRIBUTE_NAME
,
TaxonomyResourceProvider
.
TAXONOMY_NS
);
ITypedReferenceableInstance
typedInstance
=
metadataService
.
getTypedReferenceableInstance
(
entity
);
metadataService
.
createEntities
(
Collections
.
singletonList
(
typedInstance
).
toArray
(
new
ITypedReferenceableInstance
[
1
]));
final
List
<
String
>
entities
=
metadataService
.
createEntities
(
Collections
.
singletonList
(
typedInstance
).
toArray
(
new
ITypedReferenceableInstance
[
1
]));
return
entities
!=
null
&&
entities
.
size
()
>
0
?
entities
.
get
(
0
)
:
null
;
}
catch
(
EntityExistsException
e
)
{
throw
new
ResourceAlreadyExistsException
(
"Attempted to create an entity which already exists: "
+
request
.
getQueryProperties
());
...
...
@@ -115,6 +157,9 @@ public class DefaultTypeSystem implements AtlasTypeSystem {
for
(
Map
.
Entry
<
String
,
Object
>
propEntry
:
properties
.
entrySet
())
{
struct
.
set
(
propEntry
.
getKey
(),
propEntry
.
getValue
());
}
//add Taxonomy Namespace
struct
.
set
(
TaxonomyResourceProvider
.
NAMESPACE_ATTRIBUTE_NAME
,
TaxonomyResourceProvider
.
TAXONOMY_NS
);
metadataService
.
addTrait
(
guid
,
metadataService
.
createTraitInstance
(
struct
));
}
catch
(
IllegalArgumentException
e
)
{
//todo: unfortunately, IllegalArgumentException can be thrown for other reasons
...
...
@@ -151,8 +196,14 @@ public class DefaultTypeSystem implements AtlasTypeSystem {
throws
ResourceAlreadyExistsException
{
try
{
HierarchicalTypeDefinition
<
T
>
definition
=
new
HierarchicalTypeDefinition
<>(
type
,
name
,
description
,
null
,
attributes
.
toArray
(
new
AttributeDefinition
[
attributes
.
size
()]));
HierarchicalTypeDefinition
<
T
>
definition
=
null
;
if
(
isTrait
)
{
definition
=
new
HierarchicalTypeDefinition
<
T
>(
type
,
name
,
description
,
ImmutableSet
.<
String
>
of
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
),
attributes
.
toArray
(
new
AttributeDefinition
[
attributes
.
size
()]));
}
else
{
definition
=
new
HierarchicalTypeDefinition
<
T
>(
type
,
name
,
description
,
ImmutableSet
.<
String
>
of
(),
attributes
.
toArray
(
new
AttributeDefinition
[
attributes
.
size
()]));
}
metadataService
.
createType
(
TypesSerialization
.
toJson
(
definition
,
isTrait
));
}
catch
(
TypeExistsException
e
)
{
...
...
catalog/src/main/java/org/apache/atlas/catalog/TaxonomyResourceProvider.java
View file @
de0bf1db
...
...
@@ -36,6 +36,15 @@ public class TaxonomyResourceProvider extends BaseResourceProvider implements Re
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
TaxonomyResourceProvider
.
class
);
public
static
final
String
DEFAULT_TAXONOMY_NAME
=
"Catalog"
;
public
static
final
String
DEFAULT_TAXONOMY_DESCRIPTION
=
"Business Catalog"
;
public
static
final
String
NAMESPACE_ATTRIBUTE_NAME
=
"taxonomy.namespace"
;
// Taxonomy Term type
public
static
final
String
TAXONOMY_TERM_TYPE
=
"TaxonomyTerm"
;
// Taxonomy Namespace
public
static
final
String
TAXONOMY_NS
=
"atlas.taxonomy"
;
private
final
TermResourceProvider
termResourceProvider
;
// This is a cached value to prevent checking for taxonomy objects in every API call.
...
...
catalog/src/main/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinition.java
View file @
de0bf1db
...
...
@@ -20,7 +20,9 @@ package org.apache.atlas.catalog.definition;
import
com.tinkerpop.pipes.PipeFunction
;
import
com.tinkerpop.pipes.transform.TransformFunctionPipe
;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.catalog.Request
;
import
org.apache.atlas.catalog.TaxonomyResourceProvider
;
import
org.apache.atlas.catalog.VertexWrapper
;
import
org.apache.atlas.catalog.exception.InvalidPayloadException
;
import
org.apache.atlas.catalog.projection.Projection
;
...
...
@@ -37,6 +39,7 @@ public class TaxonomyResourceDefinition extends BaseResourceDefinition {
public
TaxonomyResourceDefinition
()
{
registerProperty
(
TypesUtil
.
createUniqueRequiredAttrDef
(
"name"
,
DataTypes
.
STRING_TYPE
));
registerProperty
(
TypesUtil
.
createOptionalAttrDef
(
"description"
,
DataTypes
.
STRING_TYPE
));
registerProperty
(
TypesUtil
.
createOptionalAttrDef
(
TaxonomyResourceProvider
.
NAMESPACE_ATTRIBUTE_NAME
,
DataTypes
.
STRING_TYPE
));
//todo: combine with above registrations
instanceProperties
.
add
(
"name"
);
...
...
catalog/src/test/java/org/apache/atlas/catalog/TaxonomyResourceProviderTest.java
View file @
de0bf1db
...
...
@@ -98,7 +98,7 @@ public class TaxonomyResourceProviderTest {
// mock expectations
expect
(
queryFactory
.
createTaxonomyQuery
(
capture
(
checkForAnyTaxonomiesCapture
))).
andReturn
(
query
);
expect
(
query
.
execute
()).
andReturn
(
Collections
.<
Map
<
String
,
Object
>>
emptySet
());
typeSystem
.
createEntity
(
capture
(
resourceDefinitionCapture
),
capture
(
createDefaultTaxonomyRequestCapture
)
);
expect
(
typeSystem
.
createEntity
(
capture
(
resourceDefinitionCapture
),
capture
(
createDefaultTaxonomyRequestCapture
))).
andReturn
(
"testGuid"
);
expect
(
queryFactory
.
createTaxonomyQuery
(
capture
(
requestCapture
))).
andReturn
(
query
);
expect
(
query
.
execute
()).
andReturn
(
queryResult
);
replay
(
typeSystem
,
queryFactory
,
query
);
...
...
@@ -348,7 +348,7 @@ public class TaxonomyResourceProviderTest {
// mock expectations
expect
(
queryFactory
.
createTaxonomyQuery
(
capture
(
requestCapture
))).
andReturn
(
query
);
expect
(
query
.
execute
()).
andReturn
(
queryResult
);
typeSystem
.
createEntity
(
capture
(
resourceDefinitionCapture
),
capture
(
requestCapture
)
);
expect
(
typeSystem
.
createEntity
(
capture
(
resourceDefinitionCapture
),
capture
(
requestCapture
))).
andReturn
(
"testGuid"
);
replay
(
typeSystem
,
queryFactory
,
query
);
Map
<
String
,
Object
>
requestProperties
=
new
HashMap
<>();
...
...
catalog/src/test/java/org/apache/atlas/catalog/definition/TaxonomyResourceDefinitionTest.java
View file @
de0bf1db
...
...
@@ -99,7 +99,7 @@ public class TaxonomyResourceDefinitionTest {
ResourceDefinition
taxonomyDefinition
=
new
TaxonomyResourceDefinition
();
Collection
<
AttributeDefinition
>
propertyDefinitions
=
taxonomyDefinition
.
getPropertyDefinitions
();
assertEquals
(
propertyDefinitions
.
size
(),
2
);
assertEquals
(
propertyDefinitions
.
size
(),
3
);
Set
<
String
>
defNames
=
new
HashSet
<>();
for
(
AttributeDefinition
def
:
propertyDefinitions
)
{
defNames
.
add
(
def
.
name
);
...
...
common/src/main/java/org/apache/atlas/AtlasConstants.java
View file @
de0bf1db
...
...
@@ -32,4 +32,5 @@ public final class AtlasConstants {
public
static
final
String
DEFAULT_APP_PORT_STR
=
"21000"
;
public
static
final
String
ATLAS_REST_ADDRESS_KEY
=
"atlas.rest.address"
;
public
static
final
String
DEFAULT_ATLAS_REST_ADDRESS
=
"http://localhost:21000"
;
}
pom.xml
View file @
de0bf1db
...
...
@@ -1051,6 +1051,14 @@
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-repository
</artifactId>
<version>
${project.version}
</version>
<classifier>
tests
</classifier>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.atlas
</groupId>
<artifactId>
atlas-notification
</artifactId>
<version>
${project.version}
</version>
</dependency>
...
...
release-log.txt
View file @
de0bf1db
...
...
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
ALL CHANGES:
ATLAS-986 Ability to differentiate business catalog terms from traits (sumasai,svimal2106 via shwethags)
ATLAS-1025 Set HIVE_HOME if hive is available in relative path to import hive script (svimal2106 via shwethags)
ATLAS-1009 Source HIVE_HOME and HIVE_CONF_DIR from hive_env.sh (svimal2106 via shwethags)
ATLAS-847 UI: Audit versioning does not paginate details from Atlas server (Kalyanikashikar via shwethags)
...
...
repository/pom.xml
View file @
de0bf1db
...
...
@@ -164,17 +164,18 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<version>
2.4
</version>
<configuration>
<excludes>
<exclude>
**/log4j.xml
</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>
test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
net.alchim31.maven
</groupId>
...
...
repository/src/main/java/org/apache/atlas/services/DefaultMetadataService.java
View file @
de0bf1db
...
...
@@ -25,6 +25,7 @@ import com.google.inject.Provider;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.RequestContext
;
...
...
@@ -637,7 +638,6 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
private
ITypedStruct
deserializeTraitInstance
(
String
traitInstanceDefinition
)
throws
AtlasException
{
return
createTraitInstance
(
InstanceSerialization
.
fromJsonStruct
(
traitInstanceDefinition
,
true
));
}
...
...
@@ -656,6 +656,15 @@ public class DefaultMetadataService implements MetadataService, ActiveStateChang
}
}
@Override
public
String
getTraitDefinition
(
final
String
guid
,
final
String
traitName
)
throws
AtlasException
{
ParamChecker
.
notEmpty
(
guid
,
"entity id"
);
final
ITypedReferenceableInstance
instance
=
repository
.
getEntityDefinition
(
guid
);
IStruct
struct
=
instance
.
getTrait
(
traitName
);
return
InstanceSerialization
.
toJson
(
struct
,
true
);
}
/**
* Deletes a given trait from an existing entity represented by a guid.
*
...
...
repository/src/test/java/org/apache/atlas/TestUtils.java
View file @
de0bf1db
...
...
@@ -23,9 +23,11 @@ import com.google.common.collect.ImmutableSet;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
com.tinkerpop.blueprints.util.io.graphson.GraphSONWriter
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.services.MetadataService
;
import
org.apache.atlas.typesystem.ITypedReferenceableInstance
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.TypesDef
;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.typesystem.types.AttributeDefinition
;
import
org.apache.atlas.typesystem.types.ClassType
;
...
...
@@ -40,12 +42,14 @@ import org.apache.atlas.typesystem.types.TraitType;
import
org.apache.atlas.typesystem.types.TypeSystem
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.commons.lang.RandomStringUtils
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.testng.Assert
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createClassTypeDef
;
import
static
org
.
apache
.
atlas
.
typesystem
.
types
.
utils
.
TypesUtil
.
createOptionalAttrDef
;
...
...
@@ -368,4 +372,17 @@ public final class TestUtils {
entity
.
set
(
"type"
,
"VARCHAR(32)"
);
return
entity
;
}
public
static
String
createInstance
(
MetadataService
metadataService
,
Referenceable
entity
)
throws
Exception
{
RequestContext
.
createContext
();
String
entityjson
=
InstanceSerialization
.
toJson
(
entity
,
true
);
JSONArray
entitiesJson
=
new
JSONArray
();
entitiesJson
.
put
(
entityjson
);
List
<
String
>
guids
=
metadataService
.
createEntities
(
entitiesJson
.
toString
());
if
(
guids
!=
null
&&
guids
.
size
()
>
0
)
{
return
guids
.
get
(
guids
.
size
()
-
1
);
}
return
null
;
}
}
repository/src/test/java/org/apache/atlas/service/DefaultMetadataServiceTest.java
View file @
de0bf1db
...
...
@@ -24,6 +24,7 @@ import com.google.inject.Inject;
import
com.thinkaurelius.titan.core.TitanGraph
;
import
com.thinkaurelius.titan.core.util.TitanCleanup
;
import
org.apache.atlas.AtlasClient
;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.EntityAuditEvent
;
import
org.apache.atlas.RepositoryMetadataModule
;
...
...
@@ -213,6 +214,12 @@ public class DefaultMetadataServiceTest {
assertEquals
(
traits
.
size
(),
1
);
assertEquals
(
traits
.
get
(
0
),
PII
);
//getTrait
String
traitDefinition
=
metadataService
.
getTraitDefinition
(
id
,
PII
);
Struct
traitResult
=
InstanceSerialization
.
fromJsonStruct
(
traitDefinition
,
true
);
Assert
.
assertNotNull
(
traitResult
);
Assert
.
assertEquals
(
traitResult
.
getValuesMap
().
size
(),
0
);
//delete trait
metadataService
.
deleteTrait
(
id
,
PII
);
traits
=
metadataService
.
getTraitNames
(
id
);
...
...
server-api/src/main/java/org/apache/atlas/services/MetadataService.java
View file @
de0bf1db
...
...
@@ -209,6 +209,14 @@ public interface MetadataService {
*/
ITypedStruct
createTraitInstance
(
Struct
traitInstance
)
throws
AtlasException
;
/**
* Return trait definition of a single trait for a given entity
* @param guid - Guid of the entity to which the trait is tagged
* @param traitName - Name of the trait
* @return
* @throws AtlasException
*/
String
getTraitDefinition
(
String
guid
,
String
traitName
)
throws
AtlasException
;
/**
* Deletes a given trait from an existing entity represented by a guid.
...
...
webapp/src/main/java/org/apache/atlas/web/resources/EntityService.java
View file @
de0bf1db
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.exception.CatalogException
;
import
org.apache.atlas.services.MetadataService
;
...
...
@@ -40,7 +41,7 @@ public class EntityService extends BaseService {
private
final
EntityTagResourceProvider
entityTagResourceProvider
;
@Inject
public
EntityService
(
MetadataService
metadataService
)
{
public
EntityService
(
MetadataService
metadataService
)
throws
AtlasException
{
DefaultTypeSystem
typeSystem
=
new
DefaultTypeSystem
(
metadataService
);
entityResourceProvider
=
new
EntityResourceProvider
(
typeSystem
);
entityTagResourceProvider
=
new
EntityTagResourceProvider
(
typeSystem
);
...
...
webapp/src/main/java/org/apache/atlas/web/resources/TaxonomyService.java
View file @
de0bf1db
...
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.catalog.Request
;
import
org.apache.atlas.catalog.exception.CatalogException
;
...
...
@@ -45,7 +46,7 @@ public class TaxonomyService extends BaseService {
private
ResourceProvider
termResourceProvider
;
@Inject
public
void
setMetadataService
(
MetadataService
metadataService
)
{
public
void
setMetadataService
(
MetadataService
metadataService
)
throws
AtlasException
{
DefaultTypeSystem
typeSystem
=
new
DefaultTypeSystem
(
metadataService
);
taxonomyResourceProvider
=
createTaxonomyResourceProvider
(
typeSystem
);
termResourceProvider
=
createTermResourceProvider
(
typeSystem
);
...
...
webapp/src/test/java/org/apache/atlas/web/resources/TaxonomyServiceTest.java
View file @
de0bf1db
...
...
@@ -18,6 +18,8 @@
package
org
.
apache
.
atlas
.
web
.
resources
;
import
org.apache.atlas.AtlasConstants
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.catalog.*
;
import
org.apache.atlas.services.MetadataService
;
import
org.easymock.Capture
;
...
...
@@ -55,6 +57,7 @@ public class TaxonomyServiceTest {
Result
result
=
new
Result
(
resultPropertyMaps
);
expect
(
taxonomyResourceProvider
.
getResourceById
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Get Response"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
);
...
...
@@ -95,6 +98,7 @@ public class TaxonomyServiceTest {
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
expect
(
taxonomyResourceProvider
.
getResources
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Get Response"
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
);
// instantiate service and invoke method being tested
...
...
@@ -126,6 +130,7 @@ public class TaxonomyServiceTest {
String
body
=
"{ \"description\" : \"test description\" } "
;
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
taxonomyResourceProvider
.
createResource
(
capture
(
requestCapture
));
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
...
...
@@ -162,6 +167,7 @@ public class TaxonomyServiceTest {
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
taxonomyResourceProvider
.
deleteResourceById
(
capture
(
requestCapture
));
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
// instantiate service and invoke method being tested
...
...
@@ -203,6 +209,7 @@ public class TaxonomyServiceTest {
expect
(
termResourceProvider
.
getResourceById
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Term Get Response"
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
);
TestTaxonomyService
service
=
new
TestTaxonomyService
(
...
...
@@ -243,6 +250,7 @@ public class TaxonomyServiceTest {
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
expect
(
termResourceProvider
.
getResources
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Term Get Response"
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
);
// instantiate service and invoke method being tested
...
...
@@ -290,6 +298,7 @@ public class TaxonomyServiceTest {
expect
(
segment3
.
getPath
()).
andReturn
(
"testTerm2"
);
expect
(
termResourceProvider
.
getResourceById
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Term Get Response"
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
,
segment1
,
segment2
,
segment3
);
...
...
@@ -341,6 +350,7 @@ public class TaxonomyServiceTest {
expect
(
termResourceProvider
.
getResources
(
capture
(
requestCapture
))).
andReturn
(
result
);
expect
(
serializer
.
serialize
(
result
,
uriInfo
)).
andReturn
(
"Taxonomy Term Get Response"
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
,
serializer
,
segment1
,
segment2
,
segment3
);
...
...
@@ -378,6 +388,7 @@ public class TaxonomyServiceTest {
String
body
=
"{ \"description\" : \"test description\" } "
;
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
termResourceProvider
.
createResource
(
capture
(
requestCapture
));
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
...
...
@@ -417,6 +428,7 @@ public class TaxonomyServiceTest {
String
body
=
"{ \"description\" : \"test description\" } "
;
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
termResourceProvider
.
createResource
(
capture
(
requestCapture
));
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
...
...
@@ -454,6 +466,7 @@ public class TaxonomyServiceTest {
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
termResourceProvider
.
deleteResourceById
(
capture
(
requestCapture
));
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
// instantiate service and invoke method being tested
...
...
@@ -489,6 +502,7 @@ public class TaxonomyServiceTest {
// set mock expectations
expect
(
uriInfo
.
getRequestUri
()).
andReturn
(
uri
);
termResourceProvider
.
deleteResourceById
(
capture
(
requestCapture
));
expect
(
metadataService
.
getTypeDefinition
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
)).
andReturn
(
TaxonomyResourceProvider
.
TAXONOMY_TERM_TYPE
+
"-definition"
);
replay
(
uriInfo
,
metadataService
,
taxonomyResourceProvider
,
termResourceProvider
);
// instantiate service and invoke method being tested
...
...
@@ -521,7 +535,7 @@ public class TaxonomyServiceTest {
public
TestTaxonomyService
(
MetadataService
metadataService
,
ResourceProvider
taxonomyProvider
,
ResourceProvider
termResourceProvider
,
JsonSerializer
serializer
)
{
JsonSerializer
serializer
)
throws
AtlasException
{
testTaxonomyResourceProvider
=
taxonomyProvider
;
testTermResourceProvider
=
termResourceProvider
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment