2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.action.dao.impl;
19 import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
20 import static com.datastax.driver.core.querybuilder.QueryBuilder.in;
21 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
22 import static org.openecomp.core.nosqldb.impl.cassandra.CassandraSessionFactory.getSession;
23 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY;
24 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL;
25 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME;
26 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE;
27 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT;
28 import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_VENDOR;
29 import static org.openecomp.sdc.action.ActionConstants.STATUS;
30 import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY;
31 import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_DB;
32 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER;
33 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE;
34 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG;
35 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST;
36 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ENTITY_NOT_EXIST_CODE;
37 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE;
38 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_CODE;
39 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_NOT_LOCKED_MSG;
40 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_CODE;
41 import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_QUERY_FAILURE_MSG;
43 import com.datastax.driver.core.ResultSet;
44 import com.datastax.driver.core.Row;
45 import com.datastax.driver.core.Statement;
46 import com.datastax.driver.core.UDTValue;
47 import com.datastax.driver.core.exceptions.NoHostAvailableException;
48 import com.datastax.driver.core.querybuilder.QueryBuilder;
49 import com.datastax.driver.mapping.Mapper;
50 import com.datastax.driver.mapping.Result;
51 import com.datastax.driver.mapping.UDTMapper;
52 import com.datastax.driver.mapping.annotations.Accessor;
53 import com.datastax.driver.mapping.annotations.Query;
54 import java.util.ArrayList;
55 import java.util.Collection;
56 import java.util.HashSet;
57 import java.util.LinkedHashMap;
58 import java.util.List;
61 import java.util.stream.Collectors;
62 import org.openecomp.core.dao.impl.CassandraBaseDao;
63 import org.openecomp.core.nosqldb.api.NoSqlDb;
64 import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
65 import org.openecomp.core.utilities.json.JsonUtil;
66 import org.openecomp.sdc.action.ActionConstants;
67 import org.openecomp.sdc.action.dao.ActionDao;
68 import org.openecomp.sdc.action.dao.types.ActionEntity;
69 import org.openecomp.sdc.action.dao.types.OpenEcompComponentEntity;
70 import org.openecomp.sdc.action.errors.ActionException;
71 import org.openecomp.sdc.action.logging.CategoryLogLevel;
72 import org.openecomp.sdc.action.logging.StatusCode;
73 import org.openecomp.sdc.action.types.Action;
74 import org.openecomp.sdc.action.types.ActionStatus;
75 import org.openecomp.sdc.action.types.ActionSubOperation;
76 import org.openecomp.sdc.action.types.OpenEcompComponent;
77 import org.openecomp.sdc.action.util.ActionUtil;
78 import org.openecomp.sdc.logging.api.Logger;
79 import org.openecomp.sdc.logging.api.LoggerFactory;
80 import org.openecomp.sdc.versioning.ActionVersioningManagerFactory;
81 import org.openecomp.sdc.versioning.dao.VersionInfoDao;
82 import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory;
83 import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDao;
84 import org.openecomp.sdc.versioning.dao.VersionInfoDeletedDaoFactory;
85 import org.openecomp.sdc.versioning.dao.types.Version;
86 import org.openecomp.sdc.versioning.dao.types.VersionInfoDeletedEntity;
87 import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
88 import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
92 public class ActionDaoImpl extends CassandraBaseDao<ActionEntity> implements ActionDao {
93 private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
94 private static Mapper<ActionEntity> mapper =
95 noSqlDb.getMappingManager().mapper(ActionEntity.class);
96 private static ActionAccessor accessor =
97 noSqlDb.getMappingManager().createAccessor(ActionAccessor.class);
98 private static UDTMapper<Version> versionMapper =
99 noSqlDb.getMappingManager().udtMapper(Version.class);
100 private static VersionInfoDao versionInfoDao =
101 VersionInfoDaoFactory.getInstance().createInterface();
102 private static VersionInfoDeletedDao versionInfoDeletedDao =
103 VersionInfoDeletedDaoFactory.getInstance().createInterface();
105 private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
108 public void registerVersioning(String versionableEntityType) {
109 ActionVersioningManagerFactory.getInstance().createInterface()
110 .register(versionableEntityType, new VersionableEntityMetadata(
111 mapper.getTableMetadata().getName(),
112 mapper.getTableMetadata().getPartitionKey().get(0).getName(),
113 mapper.getTableMetadata().getPartitionKey().get(1).getName()));
117 public Action createAction(Action action) {
119 ActionUtil.actionLogPreProcessor(ActionSubOperation.CREATE_ACTION_ENTITY, TARGET_ENTITY_DB);
120 this.create(action.toEntity());
121 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
124 } catch (NoHostAvailableException exception) {
125 logGenericException(exception);
126 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
127 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
132 public Action updateAction(Action action) {
134 log.debug(" entering updateAction with actionUUID= " + action.getActionUuId());
135 ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION, TARGET_ENTITY_DB);
136 this.update(action.toEntity());
137 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
139 log.debug(" exit updateAction with actionUUID= " + action.getActionUuId());
141 } catch (NoHostAvailableException exception) {
142 logGenericException(exception);
143 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
144 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
149 public void deleteAction(String actionInvariantUuId) {
151 log.debug("entering deleteAction with actionInvariantUuId = " + actionInvariantUuId);
152 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
153 VersionInfoDeletedEntity activeVersionEntity = versionInfoDeletedDao.get(
154 new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE,
155 actionInvariantUuId));
156 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
159 Version activeVersion = activeVersionEntity.getActiveVersion();
160 Statement getNameFromInvUuId = QueryBuilder.select().column("name").from("dox", "Action")
161 .where(eq("actioninvariantuuid", actionInvariantUuId))
162 .and(in("version", versionMapper.toUDT(activeVersion)));
164 .actionLogPreProcessor(ActionSubOperation.GET_NAME_BY_ACTIONINVID, TARGET_ENTITY_DB);
165 ResultSet results = getSession().execute(getNameFromInvUuId);
166 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
169 if (!results.isExhausted()) {
170 String name = results.one().getString("name");
171 List<Version> versions = getVersionsByName(name);
172 updateActionStatusForDelete(actionInvariantUuId, versions);
174 } catch (NoHostAvailableException noHostAvailableException) {
175 logGenericException(noHostAvailableException);
176 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
177 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
179 log.debug("exit deleteAction");
183 public List<Action> getFilteredActions(String filterType, String filterId) {
184 List<Action> actions = new ArrayList<>();
185 Result<ActionEntity> result = null;
187 " entering getFilteredActions By filterType = " + filterType + " With value = " + filterId);
189 switch (filterType) {
190 case FILTER_TYPE_VENDOR:
192 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_VENDOR,
194 result = accessor.getActionsByVendor(filterId);
195 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
198 case FILTER_TYPE_CATEGORY:
199 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_CATEGORY,
201 result = accessor.getActionsByCategory(filterId);
202 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
205 case FILTER_TYPE_MODEL:
207 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_MODEL,
209 result = accessor.getActionsByModel(filterId);
210 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
213 case FILTER_TYPE_OPEN_ECOMP_COMPONENT:
214 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_COMPONENT,
216 result = accessor.getActionsByOpenEcompComponent(filterId);
217 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
220 case FILTER_TYPE_NONE:
221 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ALL_ACTIONS, TARGET_ENTITY_DB);
222 result = accessor.getAllActions();
223 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
226 case FILTER_TYPE_NAME:
228 .actionLogPreProcessor(ActionSubOperation.GET_ACTIONINVID_BY_NAME, TARGET_ENTITY_DB);
229 result = accessor.getInvIdByName(filterId);
230 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE);
232 List<ActionEntity> actionEntities = result.all();
233 if (actionEntities != null && !actionEntities.isEmpty()) {
234 String actionInvariantUuId = actionEntities.get(0).getActionInvariantUuId();
235 if (actionInvariantUuId != null) {
236 return getActionsByActionInvariantUuId(actionInvariantUuId);
245 if (result != null) {
246 actions.addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
249 " exit getFilteredActions By filterType = " + filterType + " With value = " + filterId);
250 } catch (NoHostAvailableException noHostAvailableException) {
251 logGenericException(noHostAvailableException);
252 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
253 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
259 public Action getActionsByActionUuId(String actionUuId) {
261 log.debug(" entering getActionsByActionUuId with actionUUID= " + actionUuId);
262 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONUUID,
264 Result<ActionEntity> result = accessor.actionInvariantUuId(actionUuId);
265 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
267 if (result != null) {
268 log.debug(" exit getActionsByActionUuId with actionUUID= " + actionUuId);
269 ActionEntity entity = result.one();
270 if (entity != null) {
271 return entity.toDto();
274 log.debug(" exit getActionsByActionUuId with actionUUID= " + actionUuId);
276 } catch (NoHostAvailableException noHostAvailableException) {
277 logGenericException(noHostAvailableException);
278 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
279 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
284 public List<OpenEcompComponent> getOpenEcompComponents() {
285 List<OpenEcompComponent> openEcompComponents = new ArrayList<>();
286 Result<OpenEcompComponentEntity> result;
288 log.debug(" entering getOpenEcompComponents ");
290 .actionLogPreProcessor(ActionSubOperation.GET_OPEN_ECOMP_COMPONENTS_ENTITY,
292 result = accessor.getOpenEcompComponents();
293 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
295 if (result != null) {
296 openEcompComponents.addAll(
297 result.all().stream().map(OpenEcompComponentEntity::toDto)
298 .collect(Collectors.toList()));
300 } catch (NoHostAvailableException noHostAvailableException) {
301 logGenericException(noHostAvailableException);
302 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
303 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
305 log.debug(" exit getOpenEcompComponents ");
306 return openEcompComponents;
310 public List<Action> getActionsByActionInvariantUuId(String actionInvariantUuId) {
311 List<Action> actions = new ArrayList<Action>();
313 log.debug(" entering getActionsByActionInvariantUuId with actionInvariantUuId= "
314 + actionInvariantUuId);
315 Set<Version> viewableVersions = new HashSet<>();
316 VersionPredicate filter = new VersionPredicate();
317 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
318 VersionInfoEntity versionInfoEntity = versionInfoDao
319 .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
320 if (versionInfoEntity == null) {
321 //Check for action in the Delete version info table
322 VersionInfoDeletedEntity versionInfoDeletedEntity = versionInfoDeletedDao.get(
323 new VersionInfoDeletedEntity(ActionConstants.ACTION_VERSIONABLE_TYPE,
324 actionInvariantUuId));
325 if (versionInfoDeletedEntity != null) {
326 viewableVersions = versionInfoDeletedEntity.getViewableVersions();
327 //Remove intermediate minor versions from viewable versions
328 if (versionInfoDeletedEntity.getActiveVersion() != null) {
329 filter.activeVersion = versionInfoDeletedEntity.getActiveVersion();
330 filter.finalVersion = versionInfoDeletedEntity.getLatestFinalVersion();
331 viewableVersions.removeIf(filter::isIntermediateMinorVersion);
335 viewableVersions = versionInfoEntity.getViewableVersions();
336 //Remove intermediate minor versions from viewable versions
337 if (versionInfoEntity.getActiveVersion() != null) {
338 filter.activeVersion = versionInfoEntity.getActiveVersion();
339 filter.finalVersion = versionInfoEntity.getLatestFinalVersion();
340 viewableVersions.removeIf(filter::isIntermediateMinorVersion);
342 //Add candidate version if available
343 if (versionInfoEntity.getCandidate() != null) {
344 viewableVersions.add(versionInfoEntity.getCandidate().getVersion());
348 MDC.put(TARGET_ENTITY, TARGET_ENTITY_DB);
349 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
353 "Found " + viewableVersions + " viewable version for action with actionInvariantUuId "
354 + actionInvariantUuId);
356 //Fetch action data for the viewable versions
357 if (!viewableVersions.isEmpty()) {
358 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID,
360 Result<ActionEntity> result =
361 accessor.getActionsByInvId(actionInvariantUuId, viewableVersions);
362 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
364 if (result != null) {
366 .addAll(result.all().stream().map(ActionEntity::toDto).collect(Collectors.toList()));
369 } catch (NoHostAvailableException noHostAvailableException) {
370 logGenericException(noHostAvailableException);
371 throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE,
372 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG);
375 " exit getActionsByActionInvariantUuId with actionInvariantUuId= " + actionInvariantUuId);
380 public Action getLockedAction(String actionInvariantUuId, String user) throws ActionException {
381 log.debug(" entering getLockedAction with actionInvariantUuId= " + actionInvariantUuId);
382 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
383 Action action = null;
384 VersionInfoEntity versionInfoEntity = versionInfoDao
385 .get(new VersionInfoEntity(ActionConstants.ACTION_VERSIONABLE_TYPE, actionInvariantUuId));
386 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
388 if (versionInfoEntity != null) {
389 if (versionInfoEntity.getCandidate() != null) {
390 String actionUser = versionInfoEntity.getCandidate().getUser();
391 if (actionUser != null && actionUser.equals(user)) {
392 Set<Version> versions = new HashSet<>();
393 versions.add(versionInfoEntity.getCandidate().getVersion());
394 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTIONENTITY_BY_ACTIONINVID,
396 Result<ActionEntity> result = accessor.getActionsByInvId(actionInvariantUuId, versions);
397 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
399 if (result != null) {
400 ActionEntity actionEntity = result.one();
401 action = actionEntity != null ? actionEntity.toDto() : null;
404 throw new ActionException(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER_CODE,
405 String.format(ACTION_ARTIFACT_DEL_LOCKED_OTHER_USER, actionUser));
408 throw new ActionException(ACTION_NOT_LOCKED_CODE, ACTION_NOT_LOCKED_MSG);
411 throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST);
416 private void logGenericException(Exception exception) {
417 ActionUtil.actionLogPostProcessor(StatusCode.ERROR, ACTION_QUERY_FAILURE_CODE,
418 ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, false);
420 ActionUtil.actionErrorLogProcessor(CategoryLogLevel.FATAL, ACTION_QUERY_FAILURE_CODE,
421 ACTION_QUERY_FAILURE_MSG);
422 log.error(exception.getMessage());
426 protected Mapper<ActionEntity> getMapper() {
432 protected Object[] getKeys(ActionEntity entity) {
433 return new Object[]{entity.getActionInvariantUuId(), versionMapper.toUDT(entity.getVersion())};
437 public Collection<ActionEntity> list(ActionEntity entity) {
438 return accessor.getAllActions().all();
443 * @param actionInvariantUUID.
446 private void updateActionStatusForDelete(String actionInvariantUuId, List<Version> versions) {
448 "entering updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId
449 + " for versions " + versions);
450 List<UDTValue> versionUdt = new ArrayList<>();
451 for (Version v : versions) {
452 versionUdt.add(versionMapper.toUDT(v));
455 ActionUtil.actionLogPreProcessor(ActionSubOperation.UPDATE_ACTION_STATUS, TARGET_ENTITY_DB);
456 //Update the status column of action table
457 Statement updateStatusStatement =
458 QueryBuilder.update("dox", "Action").with(set("status", ActionStatus.Deleted.name()))
459 .where(eq("actioninvariantuuid", actionInvariantUuId)).and(in("version", versionUdt));
460 getSession().execute(updateStatusStatement);
461 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
463 //Update the status in the data field of action table
464 updateStatusInActionData(actionInvariantUuId, versions, ActionStatus.Deleted);
465 log.debug("exit updateActionStatusForDelete with actionInvariantUuId = " + actionInvariantUuId
466 + " for versions " + versions);
470 * Update status for a list of versions for a given action.
472 * @param actionInvariantUuId Invariant UUID of the action.
473 * @param versions List of {@link Version} for which the status has to be updated.
474 * @param status The status value.
476 private void updateStatusInActionData(String actionInvariantUuId, List<Version> versions,
477 ActionStatus status) {
478 log.debug("entering updateStatusInActionData for actionInvariantUuId = " + actionInvariantUuId
479 + " and status = " + status + " for versions " + versions);
480 for (Version v : versions) {
481 ActionEntity entity = this.get(new ActionEntity(actionInvariantUuId, v));
482 String currentData = entity.getData();
483 Map<String, Object> currentDataMap = JsonUtil.json2Object(currentData, LinkedHashMap.class);
484 currentDataMap.put(STATUS, status);
485 String updatedActionData = JsonUtil.object2Json(currentDataMap);
486 entity.setData(updatedActionData);
487 this.updateAction(entity.toDto());
489 log.debug("exit updateStatusInActionData");
493 * Get list of all major and minor version values for a given action by action name.
495 * @param name Name of the action.
496 * @return List of {@link Version} objects for the action.
498 private List<Version> getVersionsByName(String name) {
499 log.debug("entering getVersionsByName for Action Name = " + name);
500 ActionUtil.actionLogPreProcessor(ActionSubOperation.GET_ACTION_VERSION, TARGET_ENTITY_DB);
501 Statement statement =
502 QueryBuilder.select().column("version").from("dox", "Action").where(eq("name", name));
503 ResultSet results = getSession().execute(statement);
504 ActionUtil.actionLogPostProcessor(StatusCode.COMPLETE, null, "", false);
507 List<Version> versionList = new ArrayList<>();
508 for (Row row : results) {
509 Version version = versionMapper.fromUDT((UDTValue) row.getObject("version"));
510 versionList.add(version);
512 log.debug("exit getVersionsByName for Action Name = " + name);
517 interface ActionAccessor {
519 @Query("SELECT * FROM Action")
520 Result<ActionEntity> getAllActions();
522 @Query("SELECT * FROM Action where actionInvariantUuId = ? and version in ? ")
523 Result<ActionEntity> getActionsByInvId(String actionInvariantUuId, Set<Version> versions);
525 @Query("SELECT * FROM Action where supportedModels CONTAINS ?")
526 Result<ActionEntity> getActionsByModel(String resource);
528 @Query("SELECT * FROM Action where supportedComponents CONTAINS ?")
529 Result<ActionEntity> getActionsByOpenEcompComponent(String resource);
531 @Query("SELECT * FROM Action where vendor_list CONTAINS ?")
532 Result<ActionEntity> getActionsByVendor(String vendor);
534 @Query("SELECT * FROM Action where category_list CONTAINS ?")
535 Result<ActionEntity> getActionsByCategory(String vendor);
537 @Query("SELECT actionInvariantUuId FROM Action where name = ? limit 1")
538 Result<ActionEntity> getInvIdByName(String name);
540 @Query("SELECT * FROM EcompComponent")
541 Result<OpenEcompComponentEntity> getOpenEcompComponents();
543 @Query("SELECT * FROM Action where actionUUID = ?")
544 Result<ActionEntity> actionInvariantUuId(String actionUuId);
548 class VersionPredicate {
549 Version activeVersion;
550 Version finalVersion;
552 public boolean isIntermediateMinorVersion(Version version) {
553 int activeMajorVersion = activeVersion.getMajor();
554 int activeMinorVersion = activeVersion.getMinor();
555 int currentMinorVersion = version.getMinor();
556 int currentMajorVersion = version.getMajor();
558 if (finalVersion != null) {
559 if (finalVersion.getMajor() == activeMajorVersion
560 && currentMajorVersion == finalVersion.getMajor()) {
561 if (currentMinorVersion < activeMinorVersion && currentMinorVersion != 0) {
568 if (!version.equals(activeVersion)) {