2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
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;
25 import org.onap.aai.modelloader.entity.Artifact;
26 import org.onap.aai.modelloader.service.ModelLoaderMsgs;
27 import org.onap.aai.cl.api.Logger;
28 import org.onap.aai.cl.eelf.LoggerFactory;
30 import org.w3c.dom.Node;
32 public class NamedQueryArtifactParser extends AbstractModelArtifactParser {
34 private static final String NAMED_QUERY_VERSION_ID = "named-query-uuid";
35 private static final String MODEL_ELEMENT_RELATIONSHIP_KEY = "model.model-invariant-id";
37 private static Logger logger = LoggerFactory.getInstance().getLogger(NamedQueryArtifactParser.class.getName());
43 boolean processParsedModel(List<Artifact> modelList, String artifactName, IModelArtifact model) {
44 boolean valid = false;
47 logger.info(ModelLoaderMsgs.DISTRIBUTION_EVENT,
48 "Named-Query parsed =====>>>> " + "Named-Query-UUID: " + ((NamedQueryArtifact) model)
49 .getNamedQueryUuid());
50 modelList.add((NamedQueryArtifact) model);
54 logger.error(ModelLoaderMsgs.ARTIFACT_PARSE_ERROR,
55 "Unable to parse named-query artifact " + artifactName);
65 String buildArtifactParseExceptionMessage(String artifactName, String localisedMessage) {
66 return "Unable to parse named-query artifact " + artifactName + ": " + localisedMessage;
70 String getModelElementRelationshipKey() {
71 return MODEL_ELEMENT_RELATIONSHIP_KEY;
78 String getVersionIdNodeName() {
79 return NAMED_QUERY_VERSION_ID;
86 void setVersionId(IModelArtifact model, Node node) {
87 ((NamedQueryArtifact) model).setNamedQueryUuid(node.getTextContent().trim());
94 IModelArtifact createModelArtifactInstance() {
95 return new NamedQueryArtifact();
102 boolean modelIsValid(IModelArtifact model) {
103 return ((NamedQueryArtifact) model).getNamedQueryUuid() != null;