2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.action.dao.impl;
23 import com.datastax.driver.core.ResultSet;
24 import com.datastax.driver.core.Row;
25 import com.datastax.driver.core.Statement;
26 import com.datastax.driver.core.UDTValue;
27 import com.datastax.driver.core.exceptions.NoHostAvailableException;
28 import com.datastax.driver.core.querybuilder.QueryBuilder;
29 import com.datastax.driver.mapping.Mapper;
30 import com.datastax.driver.mapping.Result;
31 import com.datastax.driver.mapping.UDTMapper;
32 import com.datastax.driver.mapping.annotations.Accessor;
33 import com.datastax.driver.mapping.annotations.Query;
34 import org.openecomp.core.dao.impl.CassandraBaseDao;
35 import org.openecomp.core.nosqldb.api.NoSqlDb;
36 import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
37 import org.openecomp.core.utilities.json.JsonUtil;
38 import org.openecomp.sdc.action.ActionConstants;
39 import org.openecomp.sdc.action.dao.ActionDao;
40 import org.openecomp.sdc.action.dao.types.ActionEntity;
41 import org.openecomp.sdc.action.dao.types.OpenEcompComponentEntity;
42 import org.openecomp.sdc.action.errors.ActionException;
43 import org.openecomp.sdc.action.logging.CategoryLogLevel;
44 import org.openecomp.sdc.action.logging.StatusCode;
45 import org.openecomp.sdc.action.types.Action;
46 import org.openecomp.sdc.action.types.ActionStatus;
47 import org.openecomp.sdc.action.types.ActionSubOperation;
48 import org.openecomp.sdc.action.types.OpenEcompComponent;
49 import org.openecomp.sdc.action.util.ActionUtil;
50 import org.openecomp.sdc.logging.api.Logger;
51 import org.openecomp.sdc.logging.api.LoggerFactory;
52 import org.openecomp.sdc.versioning.VersioningManagerFactory;
53 import org.openecomp.sdc.versioning.dao.VersionInfoDao;
54 import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
55 import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDao;
56 import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDaoFactory;
57 import org.openecomp.sdc.versioning.dao.types.Version;
58 import org.openecomp.sdc.versioning.dao.types.VersionInfoDeletedEntity;
59 import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
60 import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
63 import java.util.ArrayList;
64 import java.util.Collection;
65 import java.util.HashSet;
66 import java.util.LinkedHashMap;
67 import java.util.List;
70 import java.util.stream.Collectors;
72 import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
73 import static com.datastax.driver.core.querybuilder.QueryBuilder.in;
74 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
75 import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession;
76 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
77 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
78 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
79 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
80 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
81 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
82 import static org.openecomp.sdc.action.ActionConstants.STATUS;
83 import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
84 import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
85 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER;
86 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
87 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
88 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
89 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
90 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
91 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
92 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_MSG;
93 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
94 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
97 public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements ActionDao {
98 private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
99 private static Mapper<ActionEntity> mapper =
100 noSqlDb.getMappingManager().mapper(ActionEntity.class);
101 private static ActionAccessor accessor =
102 noSqlDb.getMappingManager().createAccessor(ActionAccessor.class);
103 private static UDTMapper<Version> versionMapper =
104 noSqlDb.getMappingManager().udtMapper(Version.class);
105 private static VersionInfoDao versionInfoDao =
106 VersionInfoDaoFactory.getInstance().createInterface();
107 private static VersionInfoDeletedDao versionInfoDeletedDao =
108 VersionInfoDeletedDaoFactory.getInstance().createInterface();
110 private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
113 public void registerVersioning(String versionableEntityType) {
114 VersioningManagerFactory.getInstance().createInterface()
115 .register(versionableEntityType, new VersionableEntityMetadata(
116 mapper.getTableMetadata().getName(),
117 mapper.getTableMetadata().getPartitionKey().get(0).getName(),
118 mapper.getTableMetadata().getPartitionKey().get(1).getName()));
122 public Action createAction(Action action) {
124 ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ENTITY, TARGET_ENTITY_DB);
125 this.create(action.toEntity());
126 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
129 } catch (NoHostAvailableException exception) {
130 logGenericException(exception);
131 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
132 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
137 public Action updateAction(Action action) {
139 log.debug(" entering updateAction with actionUUID= " + action.getActionUuId());
140 ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
141 this.update(action.toEntity());
142 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
144 log.debug(" exit updateAction with actionUUID= " + action.getActionUuId());
146 } catch (NoHostAvailableException exception) {
147 logGenericException(exception);
148 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
149 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
154 public void deleteAction(String actionInvariantUuId) {
156 log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId);
157 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
158 VersionInfoDeletedEntity activeVersionEntity = versionInfoDeletedDao.get(
159 new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE,
160 actionInvariantUuId));
161 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
164 Version activeVersion = activeVersionEntity.getActiveVersion();
165 Statement getNameFromInvUuId = QueryBuilder.select().column("name").from("dox", "Action")
166 .where(eq("actioninvariantuuid", actionInvariantUuId))
167 .and(in("version", versionMapper.toUDT(activeVersion)));
169 .actionLogPreProcessor(ActionSubOperation.GET_NAME_BY_ACTIONINVID, TARGET_ENTITY_DB);
170 ResultSet results = getSession().execute(getNameFromInvUuId);
171 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
174 if (!results.isExhausted()) {
175 String name = results.one().getString("name");
176 List<Version> versions = getVersionsByName(name);
177 updateActionStatusForDelete(actionInvariantUuId, versions);
179 } catch (NoHostAvailableException noHostAvailableException) {
180 logGenericException(noHostAvailableException);
181 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
182 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
184 log.debug("exit deleteAction");
188 public List<Action> getFilteredActions(String filterType, String filterId) {
189 List<Action> actions = new ArrayList<>();
190 Result<ActionEntity> result = null;
192 " entering getFilteredActions By filterType = " + filterType + " With value = " + filterId);
194 switch (filterType) {
195 case FILTER_TYPE_VENDOR:
197 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VENDOR,
199 result = accessor.getActionsByVendor(filterId);
200 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
203 case FILTER_TYPE_CATEGORY:
204 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_CATEGORY,
206 result = accessor.getActionsByCategory(filterId);
207 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
210 case FILTER_TYPE_MODEL:
212 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_MODEL,
214 result = accessor.getActionsByModel(filterId);
215 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
218 case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
219 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_COMPONENT,
221 result = accessor.getActionsByOpenEcompComponent(filterId);
222 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
225 case FILTER_TYPE_NONE:
226 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ALL_ACTIONS, TARGET_ENTITY_DB);
227 result = accessor.getAllActions();
228 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
231 case FILTER_TYPE_NAME:
233 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONINVID_BY_NAME, TARGET_ENTITY_DB);
234 result = accessor.getInvIdByName(filterId);
235 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
237 List<ActionEntity> actionEntities = result.all();
238 if (actionEntities != null && !actionEntities.isEmpty()) {
239 String actionInvariantUuId = actionEntities.get(0).getActionInvariantUuId();
240 if (actionInvariantUuId != null) {
241 return getActionsByActionInvariantUuId(actionInvariantUuId);
250 if (result != null) {
251 actions.addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
254 " exit getFilteredActions By filterType = " + filterType + " With value = " + filterId);
255 } catch (NoHostAvailableException noHostAvailableException) {
256 logGenericException(noHostAvailableException);
257 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
258 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
264 public Action getActionsByActionUuId(String actionUuId) {
266 log.debug(" entering getActionsByActionUuId with actionUUID= " + actionUuId);
267 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONUUID,
269 Result<ActionEntity> result = accessor.actionInvariantUuId(actionUuId);
270 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
272 if (result != null) {
273 log.debug(" exit getActionsByActionUuId with actionUUID= " + actionUuId);
274 ActionEntity entity = result.one();
275 if (entity != null) {
276 return entity.toDto();
279 log.debug(" exit getActionsByActionUuId with actionUUID= " + actionUuId);
281 } catch (NoHostAvailableException noHostAvailableException) {
282 logGenericException(noHostAvailableException);
283 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
284 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
289 public List<OpenEcompComponent> getOpenEcompComponents() {
290 List<OpenEcompComponent> openEcompComponents = new ArrayList<>();
291 Result<OpenEcompComponentEntity> result;
293 log.debug(" entering getOpenEcompComponents ");
295 .actionLogPreProcessor(ActionSubOperation.GET_OPEN_ECOMP_COMPONENTS_ENTITY, TARGET_ENTITY_DB);
296 result = accessor.getOpenEcompComponents();
297 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
299 if (result != null) {
300 openEcompComponents.addAll(
301 result.all().stream().map(OpenEcompComponentEntity::toDto).collect(Collectors.toList()));
303 } catch (NoHostAvailableException noHostAvailableException) {
304 logGenericException(noHostAvailableException);
305 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
306 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
308 log.debug(" exit getOpenEcompComponents ");
309 return openEcompComponents;
313 public List<Action> getActionsByActionInvariantUuId(String actionInvariantUuId) {
314 List<Action> actions = new ArrayList<Action>();
316 log.debug(" entering getActionsByActionInvariantUuId with actionInvariantUuId= "
317 + actionInvariantUuId);
318 Set<Version> viewableVersions = new HashSet<>();
319 VersionPredicate filter = new VersionPredicate();
320 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
321 VersionInfoEntity versionInfoEntity = versionInfoDao
322 .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
323 if (versionInfoEntity == null) {
324 //Check for action in the Delete version info table
325 VersionInfoDeletedEntity versionInfoDeletedEntity = versionInfoDeletedDao.get(
326 new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE,
327 actionInvariantUuId));
328 if (versionInfoDeletedEntity != null) {
329 viewableVersions = versionInfoDeletedEntity.getViewableVersions();
330 //Remove intermediate minor versions from viewable versions
331 if (versionInfoDeletedEntity.getActiveVersion() != null) {
332 filter.activeVersion = versionInfoDeletedEntity.getActiveVersion();
333 filter.finalVersion = versionInfoDeletedEntity.getLatestFinalVersion();
334 viewableVersions.removeIf(filter::isIntermediateMinorVersion);
338 viewableVersions = versionInfoEntity.getViewableVersions();
339 //Remove intermediate minor versions from viewable versions
340 if (versionInfoEntity.getActiveVersion() != null) {
341 filter.activeVersion = versionInfoEntity.getActiveVersion();
342 filter.finalVersion = versionInfoEntity.getLatestFinalVersion();
343 viewableVersions.removeIf(filter::isIntermediateMinorVersion);
345 //Add candidate version if available
346 if (versionInfoEntity.getCandidate() != null) {
347 viewableVersions.add(versionInfoEntity.getCandidate().getVersion());
351 MDC.put(TARGET_ENTITY, TARGET_ENTITY_DB);
352 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
356 "Found " + viewableVersions + " viewable version for action with actionInvariantUuId "
357 + actionInvariantUuId);
359 //Fetch action data for the viewable versions
360 if (!viewableVersions.isEmpty()) {
361 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID,
363 Result<ActionEntity> result =
364 accessor.getActionsByInvId(actionInvariantUuId, viewableVersions);
365 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
367 if (result != null) {
369 .addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
372 } catch (NoHostAvailableException noHostAvailableException) {
373 logGenericException(noHostAvailableException);
374 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
375 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
378 " exit getActionsByActionInvariantUuId with actionInvariantUuId= " + actionInvariantUuId);
383 public Action getLockedAction(String actionInvariantUuId, String user) throws ActionException {
384 log.debug(" entering getLockedAction with actionInvariantUuId= " + actionInvariantUuId);
385 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
386 Action action = null;
387 VersionInfoEntity versionInfoEntity = versionInfoDao
388 .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
389 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
391 if (versionInfoEntity != null) {
392 if (versionInfoEntity.getCandidate() != null) {
393 String actionUser = versionInfoEntity.getCandidate().getUser();
394 if (actionUser != null && actionUser.equals(user)) {
395 Set<Version> versions = new HashSet<>();
396 versions.add(versionInfoEntity.getCandidate().getVersion());
397 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID,
399 Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, versions);
400 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
402 if (result != null) {
403 ActionEntity actionEntity = result.one();
404 action = actionEntity != null ? actionEntity.toDto() : null;
407 throw new ActionException(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE,
408 String.format(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER, actionUser));
411 throw new ActionException(ACTION_NOT_LOCKED_CODE, ACTION_NOT_LOCKED_MSG);
414 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
419 private void logGenericException(Exception exception) {
420 ActionUtil.actionLogPostProcessor(StatusCode.ERROR, ACTION_QUERY_FAILURE_CODE,
421 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
423 ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE,
424 ACTION_QUERY_FAILURE_MSG);
425 log.error(exception.getMessage());
429 protected Mapper<ActionEntity> getMapper() {
435 protected Object[] getKeys(ActionEntity entity) {
436 return new Object[]{entity.getActionInvariantUuId(), versionMapper.toUDT(entity.getVersion())};
440 public Collection<ActionEntity> list(ActionEntity entity) {
441 return accessor.getAllActions().all();
446 * @param actionInvariantUUID.
449 private void updateActionStatusForDelete(String actionInvariantUuId, List<Version> versions) {
451 "entering updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId
452 + " for versions " + versions);
453 List<UDTValue> versionUdt = new ArrayList<>();
454 for (Version v : versions) {
455 versionUdt.add(versionMapper.toUDT(v));
458 ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_STATUS, TARGET_ENTITY_DB);
459 //Update the status column of action table
460 Statement updateStatusStatement =
461 QueryBuilder.update("dox", "Action").with(set("status", ActionStatus.Deleted.name()))
462 .where(eq("actioninvariantuuid", actionInvariantUuId)).and(in("version", versionUdt));
463 getSession().execute(updateStatusStatement);
464 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
466 //Update the status in the data field of action table
467 updateStatusInActionData(actionInvariantUuId, versions, ActionStatus.Deleted);
468 log.debug("exit updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId
469 + " for versions " + versions);
473 * Update status for a list of versions for a given action.
475 * @param actionInvariantUuId Invariant UUID of the action.
476 * @param versions List of {@link Version} for which the status has to be updated.
477 * @param status The status value.
479 private void updateStatusInActionData(String actionInvariantUuId, List<Version> versions,
480 ActionStatus status) {
481 log.debug("entering updateStatusInActionData for actionInvariantUuId = " + actionInvariantUuId
482 + " and status = " + status + " for versions " + versions);
483 for (Version v : versions) {
484 ActionEntity entity = this.get(new ActionEntity(actionInvariantUuId, v));
485 String currentData = entity.getData();
486 Map<String, Object> currentDataMap = JsonUtil.json2Object(currentData, LinkedHashMap.class);
487 currentDataMap.put(STATUS, status);
488 String updatedActionData = JsonUtil.object2Json(currentDataMap);
489 entity.setData(updatedActionData);
490 this.updateAction(entity.toDto());
492 log.debug("exit updateStatusInActionData");
496 * Get list of all major and minor version values for a given action by action name.
498 * @param name Name of the action.
499 * @return List of {@link Version} objects for the action.
501 private List<Version> getVersionsByName(String name) {
502 log.debug("entering getVersionsByName for Action Name = " + name);
503 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
504 Statement statement =
505 QueryBuilder.select().column("version").from("dox", "Action").where(eq("name", name));
506 ResultSet results = getSession().execute(statement);
507 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
510 List<Version> versionList = new ArrayList<>();
511 for (Row row : results) {
512 Version version = versionMapper.fromUDT((UDTValue) row.getObject("version"));
513 versionList.add(version);
515 log.debug("exit getVersionsByName for Action Name = " + name);
520 interface ActionAccessor {
522 @Query("SELECT * FROM Action")
523 Result<ActionEntity> getAllActions();
525 @Query("SELECT * FROM Action where actionInvariantUuId = ? and version in ? ")
526 Result<ActionEntity> getActionsByInvId(String actionInvariantUuId, Set<Version> versions);
528 @Query("SELECT * FROM Action where supportedModels CONTAINS ?")
529 Result<ActionEntity> getActionsByModel(String resource);
531 @Query("SELECT * FROM Action where supportedComponents CONTAINS ?")
532 Result<ActionEntity> getActionsByOpenEcompComponent(String resource);
534 @Query("SELECT * FROM Action where vendor_list CONTAINS ?")
535 Result<ActionEntity> getActionsByVendor(String vendor);
537 @Query("SELECT * FROM Action where category_list CONTAINS ?")
538 Result<ActionEntity> getActionsByCategory(String vendor);
540 @Query("SELECT actionInvariantUuId FROM Action where name = ? limit 1")
541 Result<ActionEntity> getInvIdByName(String name);
543 @Query("SELECT * FROM EcompComponent")
544 Result<OpenEcompComponentEntity> getOpenEcompComponents();
546 @Query("SELECT * FROM Action where actionUUID = ?")
547 Result<ActionEntity> actionInvariantUuId(String actionUuId);
551 class VersionPredicate {
552 Version activeVersion;
553 Version finalVersion;
555 public boolean isIntermediateMinorVersion(Version version) {
556 int activeMajorVersion = activeVersion.getMajor();
557 int activeMinorVersion = activeVersion.getMinor();
558 int currentMinorVersion = version.getMinor();
559 int currentMajorVersion = version.getMajor();
561 if (finalVersion != null) {
562 if (finalVersion.getMajor() == activeMajorVersion
563 && currentMajorVersion == finalVersion.getMajor()) {
564 if (currentMinorVersion < activeMinorVersion && currentMinorVersion != 0) {
571 if (!version.equals(activeVersion)) {