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