You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
package de.superx.bianalysis.repository; |
|
|
|
import java.util.List; |
|
import java.util.Optional; |
|
|
|
import org.springframework.data.jdbc.repository.query.Query; |
|
import org.springframework.data.repository.CrudRepository; |
|
import org.springframework.data.repository.RepositoryDefinition; |
|
import org.springframework.data.repository.query.Param; |
|
|
|
import de.superx.bianalysis.FaultyMetadataException; |
|
import de.superx.bianalysis.metadata.Identifier; |
|
import de.superx.bianalysis.repository.dto.DimensionDto; |
|
import de.superx.jdbc.repository.BiaAdminCrudRepository; |
|
|
|
@RepositoryDefinition(domainClass = DimensionDto.class, idClass = Identifier.class) |
|
public interface DimensionRepository extends BiaAdminCrudRepository<DimensionDto> { |
|
|
|
List<DimensionDto> findByFactTableId(Identifier factTableId); |
|
|
|
Optional<DimensionDto> findById(Identifier id); |
|
|
|
@Override |
|
List<DimensionDto> findAll(); |
|
|
|
@Query( |
|
" SELECT d.id" |
|
+ " FROM metadata.dimension d" |
|
+ " LEFT JOIN metadata.dimension_attribute da" |
|
+ " ON da.dimension_id = d.id" |
|
+ " WHERE da.id is null" |
|
+ " AND d.conformed = :confDim" |
|
+ " AND d.facttable_id = :factId" |
|
) |
|
List<Identifier> getRolePlayingIds(@Param("confDim") String confDim, @Param("factId") String factId); |
|
|
|
@Query( |
|
"SELECT dimension_id " |
|
+ "FROM metadata.dimension_attribute da " |
|
+ "WHERE id = :attrId" |
|
) |
|
Identifier findDimensionIdForAttribute(@Param("attrId") String attrId); |
|
|
|
@Query( |
|
"SELECT conformed" |
|
+ " FROM metadata.dimension" |
|
+ " WHERE facttable_id = :factId" |
|
+ " AND conformed IS NOT NULL" |
|
) |
|
List<Identifier> getUsedConformedDimensionsByFactTable(@Param("factId") String factId); |
|
|
|
default DimensionDto findByIdOrThrow(Identifier id) { |
|
return findById(id) |
|
.orElseThrow(() -> new FaultyMetadataException(id)); |
|
} |
|
}
|
|
|