2 * Copyright (c) 2018 Orange
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.
16 package org.onap.nbi.apis.serviceorder.repositories;
18 import org.onap.nbi.apis.serviceorder.model.orchestrator.ExecutionTask;
19 import org.springframework.data.jpa.repository.Modifying;
20 import org.springframework.data.jpa.repository.Query;
21 import org.springframework.data.repository.CrudRepository;
22 import org.springframework.data.repository.query.Param;
23 import org.springframework.transaction.annotation.Propagation;
24 import org.springframework.transaction.annotation.Transactional;
25 import java.util.List;
27 public interface ExecutionTaskRepository extends CrudRepository<ExecutionTask, Long> {
29 @Query("SELECT t FROM ExecutionTask t WHERE TRIM(t.reliedTasks) LIKE '' ")
30 List<ExecutionTask> findByReliedTasksIsEmpty();
32 @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
34 @Query("UPDATE ExecutionTask t SET t.reliedTasks = REPLACE(t.reliedTasks, :internalId, '') WHERE t.reliedTasks "
35 + "LIKE CONCAT('%', :internalId, '%')")
36 void updateReliedTaskAfterDelete(@Param("internalId") Long internalId);
38 @Query("SELECT t FROM ExecutionTask t WHERE t.reliedTasks LIKE CONCAT('%', :internalId, '%')")
39 List<ExecutionTask> findTasksReliedToAnOrderItemId(@Param("internalId") Long internalId);