Skip to content

Commit

Permalink
Using org hierarchy v4 table
Browse files Browse the repository at this point in the history
  • Loading branch information
karthik-tarento authored May 19, 2023
1 parent 5bfeb9d commit 0cffa05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/sunbird/org/model/OrgHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "org_hierarchy_v2")
@Table(name = "org_hierarchy_v4")
public class OrgHierarchy {
@Id
@Column(name = "id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.sunbird.org.model.OrgHierarchy;

public interface OrgHierarchyRepository extends JpaRepository<OrgHierarchy, Integer> {
@Query(value = "SELECT * FROM org_hierarchy_v2 org WHERE org.orgname ~* ?1", nativeQuery = true)
@Query(value = "SELECT * FROM org_hierarchy_v4 org WHERE org.orgname ~* ?1", nativeQuery = true)
List<OrgHierarchy> searchOrgWithHierarchy(String orgName);

List<OrgHierarchy> findAllByOrgName(String orgName);
Expand All @@ -20,10 +20,10 @@ public interface OrgHierarchyRepository extends JpaRepository<OrgHierarchy, Inte

OrgHierarchy findByMapId(String mapId);

@Query(value = "SELECT sborgid from org_hierarchy_v2 where mapid=?1", nativeQuery = true)
@Query(value = "SELECT sborgid from org_hierarchy_v4 where mapid=?1", nativeQuery = true)
String getSbOrgIdFromMapId(String mapId);

@Query(value = "SELECT * FROM org_hierarchy_v2 where LOWER(parentmapid)=LOWER(?1)", nativeQuery = true)
@Query(value = "SELECT * FROM org_hierarchy_v4 where LOWER(parentmapid)=LOWER(?1)", nativeQuery = true)
List<OrgHierarchy> findAllByParentMapId(String parentMapId);

List<OrgHierarchy> findAllBySbOrgType(String orgType);
Expand All @@ -32,21 +32,21 @@ public interface OrgHierarchyRepository extends JpaRepository<OrgHierarchy, Inte

@Transactional
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE org_hierarchy_v2 set sborgid=?2 where channel=?1", nativeQuery = true)
@Query(value = "UPDATE org_hierarchy_v4 set sborgid=?2 where channel=?1", nativeQuery = true)
void updateOrgIdForChannel(String channel, String sbOrgId);

@Transactional
@Modifying(clearAutomatically = true)
@Query(value = "UPDATE org_hierarchy_v2 set sborgid=?2, sbrootorgid=?3 where channel=?1", nativeQuery = true)
@Query(value = "UPDATE org_hierarchy_v4 set sborgid=?2, sbrootorgid=?3 where channel=?1", nativeQuery = true)
void updateSbOrgIdAndSbOrgRootIdForChannel(String channel, String sbOrgId, String sbRootOrgId);

@Query(value = "SELECT sborgid from org_hierarchy_v2 where sbrootorgid=?1", nativeQuery = true)
@Query(value = "SELECT sborgid from org_hierarchy_v4 where sbrootorgid=?1", nativeQuery = true)
List<String> findAllBySbRootOrgId(String sbRootOrgId);

@Query(value = "SELECT sborgid from org_hierarchy_v2 where sbrootorgid in (?1)", nativeQuery = true)
@Query(value = "SELECT sborgid from org_hierarchy_v4 where sbrootorgid in (?1)", nativeQuery = true)
List<String> fetchL2LevelOrgList(List<String> orgIdList);

@Query(value = "SELECT * from org_hierarchy_v2 where mapid in (?1)", nativeQuery = true)
@Query(value = "SELECT * from org_hierarchy_v4 where mapid in (?1)", nativeQuery = true)
List<OrgHierarchy> searchOrgForL1MapId(Set<String> l1MapIdSet);

OrgHierarchy findByOrgNameAndParentMapId(String orgName, String parentMapId);
Expand Down

0 comments on commit 0cffa05

Please sign in to comment.