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
f4dac184
Commit
f4dac184
authored
Sep 26, 2018
by
Ashutosh Mestry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2892: Delete by name REST endpoint.
Change-Id: I9b0a40b42bc945f51aa098e1b15f28f7d2c9fee2 Signed-off-by:
Ashutosh Mestry
<
amestry@hortonworks.com
>
parent
b04c5bd2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
135 additions
and
6 deletions
+135
-6
VTag.js
dashboardv2/public/js/models/VTag.js
+1
-5
TagLayoutView.js
dashboardv2/public/js/views/tag/TagLayoutView.js
+1
-1
AtlasTypeDefStore.java
...c/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
+3
-0
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+26
-0
AtlasTypeDefGraphStoreTest.java
...as/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+21
-0
hiveDBv2.json
repository/src/test/resources/json/hiveDBv2.json
+57
-0
TypesREST.java
...pp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
+26
-0
No files found.
dashboardv2/public/js/models/VTag.js
View file @
f4dac184
...
...
@@ -49,11 +49,7 @@ define(['require',
return
this
.
constructor
.
nonCrudOperation
.
call
(
this
,
url
,
'DELETE'
,
options
);
},
deleteTag
:
function
(
options
)
{
var
url
=
UrlLinks
.
classificationDefApiUrl
();
options
=
_
.
extend
({
contentType
:
'application/json'
,
dataType
:
'json'
},
options
);
var
url
=
UrlLinks
.
classificationDefApiUrl
(
options
.
typeName
);
return
this
.
constructor
.
nonCrudOperation
.
call
(
this
,
url
,
'DELETE'
,
options
);
},
saveTagAttribute
:
function
(
options
)
{
...
...
dashboardv2/public/js/views/tag/TagLayoutView.js
View file @
f4dac184
...
...
@@ -578,7 +578,7 @@ define(['require',
structDefs
:
[]
};
deleteTagData
.
deleteTag
({
data
:
JSON
.
stringify
(
deleteJson
)
,
typeName
:
that
.
tag
,
success
:
function
()
{
Utils
.
notifySuccess
({
content
:
"Classification "
+
that
.
tag
+
Messages
.
deleteSuccessMessage
...
...
intg/src/main/java/org/apache/atlas/store/AtlasTypeDefStore.java
View file @
f4dac184
...
...
@@ -99,8 +99,11 @@ public interface AtlasTypeDefStore {
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
;
/* Generic operation */
AtlasBaseTypeDef
getByName
(
String
name
)
throws
AtlasBaseException
;
AtlasBaseTypeDef
getByGuid
(
String
guid
)
throws
AtlasBaseException
;
void
deleteTypeByName
(
String
typeName
)
throws
AtlasBaseException
;
}
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
f4dac184
...
...
@@ -40,6 +40,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -598,6 +599,31 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore {
}
}
@Override
@GraphTransaction
public
void
deleteTypeByName
(
String
typeName
)
throws
AtlasBaseException
{
AtlasType
atlasType
=
typeRegistry
.
getType
(
typeName
);
if
(
atlasType
==
null
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_PARAMETERS
.
TYPE_NAME_NOT_FOUND
,
typeName
);
}
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
AtlasBaseTypeDef
baseTypeDef
=
getByName
(
typeName
);
if
(
baseTypeDef
instanceof
AtlasClassificationDef
)
{
typesDef
.
setClassificationDefs
(
Collections
.
singletonList
((
AtlasClassificationDef
)
baseTypeDef
));
}
else
if
(
baseTypeDef
instanceof
AtlasEntityDef
)
{
typesDef
.
setEntityDefs
(
Collections
.
singletonList
((
AtlasEntityDef
)
baseTypeDef
));
}
else
if
(
baseTypeDef
instanceof
AtlasEnumDef
)
{
typesDef
.
setEnumDefs
(
Collections
.
singletonList
((
AtlasEnumDef
)
baseTypeDef
));
}
else
if
(
baseTypeDef
instanceof
AtlasStructDef
)
{
typesDef
.
setStructDefs
(
Collections
.
singletonList
((
AtlasStructDef
)
baseTypeDef
));
}
deleteTypesDef
(
typesDef
);
}
@Override
public
AtlasTypesDef
searchTypesDef
(
SearchFilter
searchFilter
)
throws
AtlasBaseException
{
final
AtlasTypesDef
typesDef
=
new
AtlasTypesDef
();
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
View file @
f4dac184
...
...
@@ -24,10 +24,16 @@ import org.apache.atlas.TestUtilsV2;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.SearchFilter
;
import
org.apache.atlas.model.typedef.*
;
import
org.apache.atlas.model.impexp.AtlasExportRequest
;
import
org.apache.atlas.model.typedef.AtlasClassificationDef
;
import
org.apache.atlas.model.typedef.AtlasEntityDef
;
import
org.apache.atlas.model.typedef.AtlasEnumDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.runner.LocalSolrRunner
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.utils.TestResourceFileUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.Assert
;
...
...
@@ -40,6 +46,8 @@ import java.util.Collections;
import
java.util.List
;
import
java.util.Set
;
import
java.util.HashSet
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Date
;
...
...
@@ -319,6 +327,19 @@ public class AtlasTypeDefGraphStoreTest {
}
}
@Test
public
void
deleteTypeByName
()
throws
IOException
{
try
{
final
String
HIVEDB_v2_JSON
=
"hiveDBv2"
;
final
String
hiveDB2
=
"hive_db_v2"
;
AtlasTypesDef
typesDef
=
TestResourceFileUtils
.
readObjectFromJson
(
"."
,
HIVEDB_v2_JSON
,
AtlasTypesDef
.
class
);
typeDefStore
.
createTypesDef
(
typesDef
);
typeDefStore
.
deleteTypeByName
(
hiveDB2
);
}
catch
(
AtlasBaseException
e
)
{
fail
(
"Deletion should've succeeded"
);
}
}
@Test
(
dependsOnMethods
=
"testGet"
)
public
void
testCreateWithValidAttributes
(){
AtlasTypesDef
hiveTypes
=
TestUtilsV2
.
defineHiveTypes
();
...
...
repository/src/test/resources/json/hiveDBv2.json
0 → 100644
View file @
f4dac184
{
"enumDefs"
:
[],
"structDefs"
:
[],
"classificationDefs"
:
[],
"entityDefs"
:
[{
"category"
:
"ENTITY"
,
"name"
:
"hive_db_v2"
,
"typeVersion"
:
"1.0"
,
"attributeDefs"
:
[{
"name"
:
"name"
,
"typeName"
:
"string"
,
"isOptional"
:
false
,
"cardinality"
:
"SINGLE"
,
"valuesMinCount"
:
1
,
"valuesMaxCount"
:
1
,
"isUnique"
:
true
,
"isIndexable"
:
true
},
{
"name"
:
"description"
,
"typeName"
:
"string"
,
"isOptional"
:
false
,
"cardinality"
:
"SINGLE"
,
"valuesMinCount"
:
1
,
"valuesMaxCount"
:
1
,
"isUnique"
:
false
,
"isIndexable"
:
true
},
{
"name"
:
"locationUri"
,
"typeName"
:
"string"
,
"isOptional"
:
true
,
"cardinality"
:
"SINGLE"
,
"valuesMinCount"
:
0
,
"valuesMaxCount"
:
1
,
"isUnique"
:
false
,
"isIndexable"
:
false
},
{
"name"
:
"owner"
,
"typeName"
:
"string"
,
"isOptional"
:
true
,
"cardinality"
:
"SINGLE"
,
"valuesMinCount"
:
0
,
"valuesMaxCount"
:
1
,
"isUnique"
:
false
,
"isIndexable"
:
false
},
{
"name"
:
"createTime"
,
"typeName"
:
"int"
,
"isOptional"
:
true
,
"cardinality"
:
"SINGLE"
,
"valuesMinCount"
:
0
,
"valuesMaxCount"
:
1
,
"isUnique"
:
false
,
"isIndexable"
:
false
}]
}]
}
\ No newline at end of file
webapp/src/main/java/org/apache/atlas/web/rest/TypesREST.java
View file @
f4dac184
...
...
@@ -41,6 +41,7 @@ import javax.inject.Singleton;
import
javax.servlet.http.HttpServletRequest
;
import
javax.ws.rs.*
;
import
javax.ws.rs.core.Context
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -410,6 +411,31 @@ public class TypesREST {
}
/**
* Delete API for type identified by its name.
* @param typeName Name of the type to be deleted.
* @throws AtlasBaseException
* @HTTP 204 On successful deletion of the requested type definitions
* @HTTP 400 On validation failure for any type definitions
*/
@DELETE
@Path
(
"/typedef/name/{typeName}"
)
@Consumes
(
Servlets
.
JSON_MEDIA_TYPE
)
@Produces
(
Servlets
.
JSON_MEDIA_TYPE
)
public
void
deleteAtlasTypeByName
(
@PathParam
(
"typeName"
)
final
String
typeName
)
throws
AtlasBaseException
{
AtlasPerfTracer
perf
=
null
;
try
{
if
(
AtlasPerfTracer
.
isPerfTraceEnabled
(
PERF_LOG
))
{
perf
=
AtlasPerfTracer
.
getPerfTracer
(
PERF_LOG
,
"TypesREST.deleteAtlasTypeByName("
+
typeName
+
")"
);
}
typeDefStore
.
deleteTypeByName
(
typeName
);
}
finally
{
AtlasPerfTracer
.
log
(
perf
);
}
}
/**
* Populate a SearchFilter on the basis of the Query Parameters
* @return
*/
...
...
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