2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 European Software Marketing Ltd.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.modelloader.entity.model;
23 import java.util.List;
24 import org.onap.aai.cl.api.Logger;
25 import org.onap.aai.cl.eelf.LoggerFactory;
26 import org.onap.aai.modelloader.entity.Artifact;
27 import org.onap.aai.modelloader.service.ModelLoaderMsgs;
28 import org.w3c.dom.Node;
30 public class NamedQueryArtifactParser extends AbstractModelArtifactParser {
32 private static final String NAMED_QUERY_VERSION_ID = "named-query-uuid";
33 private static final String MODEL_ELEMENT_RELATIONSHIP_KEY = "model.model-invariant-id";
35 private static Logger logger = LoggerFactory.getInstance().getLogger(NamedQueryArtifactParser.class.getName());
41 boolean processParsedModel(List<Artifact> modelList, String artifactName, IModelArtifact model) {
42 boolean valid = false;
45 logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT, "Named-Query parsed =====>>>> " + "Named-Query-UUID: "
46 + ((NamedQueryArtifact) model).getNamedQueryUuid());
47 modelList.add((NamedQueryArtifact) model);
51 logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR, "Unable to parse named-query artifact " + artifactName);
61 String buildArtifactParseExceptionMessage(String artifactName, String localisedMessage) {
62 return "Unable to parse named-query artifact " + artifactName + ": " + localisedMessage;
66 String getModelElementRelationshipKey() {
67 return MODEL_ELEMENT_RELATIONSHIP_KEY;
74 String getVersionIdNodeName() {
75 return NAMED_QUERY_VERSION_ID;
82 void setVersionId(IModelArtifact model, Node node) {
83 ((NamedQueryArtifact) model).setNamedQueryUuid(node.getTextContent().trim());
90 IModelArtifact createModelArtifactInstance() {
91 return new NamedQueryArtifact();
98 boolean modelIsValid(IModelArtifact model) {
99 return ((NamedQueryArtifact) model).getNamedQueryUuid() != null;