package com.cloudhandson.vpdbackoffice.mapper;

import com.cloudhandson.vpdbackoffice.domain.schemametadata.SchemaMetadataAnnotationRow;
import com.cloudhandson.vpdbackoffice.domain.schemametadata.SchemaMetadataColumnRow;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * All database access for the schema metadata screen. Identifier parameters
 * are validated against the screen's closed table list before mapper calls.
 */
@Mapper
public interface SchemaMetadataMapper {

  String findTableComment(@Param("owner") String owner, @Param("tableName") String tableName);

  List<SchemaMetadataColumnRow> findColumns(
      @Param("owner") String owner,
      @Param("tableName") String tableName
  );

  List<SchemaMetadataAnnotationRow> findAnnotations(@Param("tableName") String tableName);

  int countColumn(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("columnName") String columnName
  );

  int countTableAnnotation(
      @Param("tableName") String tableName,
      @Param("annotationName") String annotationName
  );

  int countColumnAnnotation(
      @Param("tableName") String tableName,
      @Param("columnName") String columnName,
      @Param("annotationName") String annotationName
  );

  void updateTableComment(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("commentLiteral") String commentLiteral
  );

  void updateColumnComment(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("columnName") String columnName,
      @Param("commentLiteral") String commentLiteral
  );

  void dropTableAnnotation(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("annotationName") String annotationName
  );

  void addTableAnnotation(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("annotationName") String annotationName,
      @Param("annotationValueLiteral") String annotationValueLiteral
  );

  void dropColumnAnnotation(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("columnName") String columnName,
      @Param("annotationName") String annotationName
  );

  void addColumnAnnotation(
      @Param("owner") String owner,
      @Param("tableName") String tableName,
      @Param("columnName") String columnName,
      @Param("annotationName") String annotationName,
      @Param("annotationValueLiteral") String annotationValueLiteral
  );
}
