forked from apache/atlas
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3347 from atlanhq/policyendpointsmasterss
DG-1697: Adding endpoint for linking/unlink policy
- Loading branch information
Showing
10 changed files
with
407 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
intg/src/main/java/org/apache/atlas/model/instance/LinkBusinessPolicyRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.atlas.model.instance; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
|
||
import javax.xml.bind.annotation.XmlAccessType; | ||
import javax.xml.bind.annotation.XmlAccessorType; | ||
import javax.xml.bind.annotation.XmlRootElement; | ||
import java.io.Serializable; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; | ||
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; | ||
|
||
/** | ||
* Request to link/unlink policies from asset. | ||
*/ | ||
@JsonAutoDetect(getterVisibility = PUBLIC_ONLY, setterVisibility = PUBLIC_ONLY, fieldVisibility = NONE) | ||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@XmlRootElement | ||
@XmlAccessorType(XmlAccessType.PROPERTY) | ||
public class LinkBusinessPolicyRequest implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private Set<String> linkGuids; | ||
private Set<String> unlinkGuids; | ||
|
||
public Set<String> getLinkGuids() { | ||
return linkGuids; | ||
} | ||
|
||
public void setLinkGuids(Set<String> linkGuids) { | ||
this.linkGuids = linkGuids; | ||
} | ||
|
||
public Set<String> getUnlinkGuids() { | ||
return unlinkGuids; | ||
} | ||
|
||
public void setUnlinkGuids(Set<String> unlinkGuids) { | ||
this.unlinkGuids = unlinkGuids; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("LinkBusinessPolicyRequest{"); | ||
sb.append("linkGuids=").append(linkGuids); | ||
sb.append(", unlinkGuids=").append(unlinkGuids); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
.../src/main/java/org/apache/atlas/repository/store/graph/v2/BusinessPolicyNotifierImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.apache.atlas.repository.store.graph.v2; | ||
|
||
import org.apache.atlas.RequestContext; | ||
import org.apache.atlas.exception.AtlasBaseException; | ||
import org.apache.atlas.listener.EntityChangeListenerV2; | ||
import org.apache.atlas.model.instance.AtlasEntity; | ||
import org.apache.atlas.repository.graphdb.AtlasVertex; | ||
import org.apache.atlas.utils.AtlasPerfMetrics; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.inject.Inject; | ||
import java.util.*; | ||
|
||
import static org.apache.atlas.repository.Constants.*; | ||
import static org.apache.atlas.repository.graph.GraphHelper.*; | ||
|
||
|
||
@Component | ||
public class BusinessPolicyNotifierImpl implements IAtlasMinimalChangeNotifier { | ||
|
||
private final Set<EntityChangeListenerV2> entityChangeListenersV2; | ||
|
||
@Inject | ||
public BusinessPolicyNotifierImpl(Set<EntityChangeListenerV2> entityChangeListenersV2) { | ||
this.entityChangeListenersV2 = entityChangeListenersV2; | ||
|
||
} | ||
|
||
@Override | ||
public void onEntitiesMutation(final List<AtlasVertex> vertices) throws AtlasBaseException { | ||
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("onEntitiesMutation"); | ||
final List<AtlasEntity> entities = new ArrayList<>(0); | ||
vertices.forEach(item -> entities.add(createAtlasEntity(item))); | ||
for (EntityChangeListenerV2 listener : entityChangeListenersV2) { | ||
listener.onEntitiesUpdated(entities, false); | ||
} | ||
|
||
RequestContext.get().endMetricRecord(metricRecorder); | ||
} | ||
|
||
private AtlasEntity createAtlasEntity(AtlasVertex vertex) { | ||
AtlasEntity atlasEntity = new AtlasEntity(); | ||
atlasEntity.setAttribute(QUALIFIED_NAME, vertex.getProperty(QUALIFIED_NAME, String.class)); | ||
atlasEntity.setAttribute(NAME, vertex.getProperty(NAME, String.class)); | ||
|
||
atlasEntity.setGuid(vertex.getProperty(GUID_PROPERTY_KEY, String.class)); | ||
atlasEntity.setTypeName(vertex.getProperty(TYPE_NAME_PROPERTY_KEY, String.class)); | ||
atlasEntity.setCreatedBy(vertex.getProperty(CREATED_BY_KEY, String.class)); | ||
atlasEntity.setUpdatedBy(vertex.getProperty(MODIFIED_BY_KEY, String.class)); | ||
atlasEntity.setCreateTime(new Date(vertex.getProperty(TIMESTAMP_PROPERTY_KEY, Long.class))); | ||
atlasEntity.setUpdateTime(new Date(vertex.getProperty(MODIFICATION_TIMESTAMP_PROPERTY_KEY, Long.class))); | ||
atlasEntity.setIsProxy(vertex.getProperty(IS_PROXY_KEY, Boolean.class)); | ||
atlasEntity.setIsIncomplete(vertex.getProperty(IS_INCOMPLETE_PROPERTY_KEY, Boolean.class)); | ||
atlasEntity.setStatus(getStatus(vertex)); | ||
atlasEntity.setProvenanceType(getProvenanceType(vertex)); | ||
atlasEntity.setHomeId(getHomeId(vertex)); | ||
atlasEntity.setVersion(getVersion(vertex)); | ||
|
||
|
||
return atlasEntity; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.