|
32 | 32 | import org.apache.atlas.model.instance.AtlasObjectId;
|
33 | 33 | import org.apache.atlas.model.tasks.AtlasTask;
|
34 | 34 | import org.apache.atlas.repository.graph.GraphHelper;
|
35 |
| -import org.apache.atlas.repository.graphdb.AtlasEdgeDirection; |
36 | 35 | import org.apache.atlas.repository.graphdb.AtlasGraph;
|
37 | 36 | import org.apache.atlas.repository.graphdb.AtlasVertex;
|
38 | 37 | import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
|
|
50 | 49 |
|
51 | 50 | import java.util.ArrayList;
|
52 | 51 | import java.util.HashSet;
|
53 |
| -import java.util.Iterator; |
54 | 52 | import java.util.List;
|
55 | 53 | import java.util.Map;
|
56 | 54 | import java.util.Set;
|
57 | 55 | import java.util.stream.Collectors;
|
58 | 56 |
|
59 |
| -import static org.apache.atlas.repository.Constants.ACTIVE_STATE_VALUE; |
60 | 57 | import static org.apache.atlas.repository.Constants.ATLAS_GLOSSARY_TERM_ENTITY_TYPE;
|
61 | 58 | import static org.apache.atlas.repository.Constants.ELASTICSEARCH_PAGINATION_SIZE;
|
62 | 59 | import static org.apache.atlas.repository.Constants.NAME;
|
@@ -109,13 +106,7 @@ public void termExists(String termName, String glossaryQName) throws AtlasBaseEx
|
109 | 106 | List<AtlasEntityHeader> terms = indexSearchPaginated(dsl);
|
110 | 107 |
|
111 | 108 | if (CollectionUtils.isNotEmpty(terms)) {
|
112 |
| - for (AtlasEntityHeader term : terms) { |
113 |
| - String name = (String) term.getAttribute(NAME); |
114 |
| - if (termName.equals(name)) { |
115 |
| - ret = true; |
116 |
| - break; |
117 |
| - } |
118 |
| - } |
| 109 | + ret = terms.stream().map(term -> (String) term.getAttribute(NAME)).anyMatch(name -> termName.equals(name)); |
119 | 110 | }
|
120 | 111 |
|
121 | 112 | if (ret) {
|
@@ -143,8 +134,7 @@ public void createAndQueueTask(String taskType,
|
143 | 134 | public boolean checkEntityTermAssociation(String termQName) throws AtlasBaseException {
|
144 | 135 | List<AtlasEntityHeader> entityHeader;
|
145 | 136 | entityHeader = discovery.searchUsingTermQualifiedName(0,1,termQName,null,null);
|
146 |
| - Boolean hasEntityAssociation = entityHeader != null ? true : false; |
147 |
| - return hasEntityAssociation; |
| 137 | + return entityHeader != null; |
148 | 138 | }
|
149 | 139 |
|
150 | 140 | public List<AtlasEntityHeader> indexSearchPaginated(Map<String, Object> dsl) throws AtlasBaseException {
|
@@ -234,45 +224,6 @@ public void updateMeaningsAttributesInEntitiesOnTermUpdate(String currentTermNam
|
234 | 224 | }
|
235 | 225 | }
|
236 | 226 |
|
237 |
| - /** |
238 |
| - * Get all the active parents |
239 |
| - * @param vertex entity vertex |
240 |
| - * @param parentEdgeLabel Edge label of parent |
241 |
| - * @return Iterator of children vertices |
242 |
| - */ |
243 |
| - protected Iterator<AtlasVertex> getActiveParents(AtlasVertex vertex, String parentEdgeLabel) throws AtlasBaseException { |
244 |
| - return getEdges(vertex, parentEdgeLabel, AtlasEdgeDirection.IN); |
245 |
| - } |
246 |
| - |
247 |
| - /** |
248 |
| - * Get all the active children of category |
249 |
| - * @param vertex entity vertex |
250 |
| - * @param childrenEdgeLabel Edge label of children |
251 |
| - * @return Iterator of children vertices |
252 |
| - */ |
253 |
| - protected Iterator<AtlasVertex> getActiveChildren(AtlasVertex vertex, String childrenEdgeLabel) throws AtlasBaseException { |
254 |
| - return getEdges(vertex, childrenEdgeLabel, AtlasEdgeDirection.OUT); |
255 |
| - } |
256 |
| - |
257 |
| - protected Iterator getEdges(AtlasVertex vertex, String childrenEdgeLabel, AtlasEdgeDirection direction) throws AtlasBaseException { |
258 |
| - AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("CategoryPreProcessor.getEdges"); |
259 |
| - |
260 |
| - try { |
261 |
| - return vertex.query() |
262 |
| - .direction(direction) |
263 |
| - .label(childrenEdgeLabel) |
264 |
| - .has(STATE_PROPERTY_KEY, ACTIVE_STATE_VALUE) |
265 |
| - .vertices() |
266 |
| - .iterator(); |
267 |
| - } catch (Exception e) { |
268 |
| - LOG.error("Error while getting active children of category for edge label " + childrenEdgeLabel, e); |
269 |
| - throw new AtlasBaseException(AtlasErrorCode.INTERNAL_ERROR, e); |
270 |
| - } |
271 |
| - finally { |
272 |
| - RequestContext.get().endMetricRecord(metricRecorder); |
273 |
| - } |
274 |
| - } |
275 |
| - |
276 | 227 | protected void isAuthorized(AtlasEntityHeader sourceGlossary, AtlasEntityHeader targetGlossary) throws AtlasBaseException {
|
277 | 228 |
|
278 | 229 | // source -> CREATE + UPDATE + DELETE
|
|
0 commit comments