package com.cloudhandson.vpdbackoffice.mapper;

import com.cloudhandson.vpdbackoffice.domain.protectedobject.DatabaseObjectOption;
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedColumn;
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedObjectCreateCommand;
import com.cloudhandson.vpdbackoffice.domain.protectedobject.ProtectedObject;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

@Mapper
public interface ProtectedObjectMapper {

  List<ProtectedObject> findEnabled();

  List<ProtectedObject> findEnabledWithPermissions();

  ProtectedObject findById(@Param("objectId") long objectId);

  ProtectedObject findByOwnerAndName(@Param("owner") String owner, @Param("objectName") String objectName);

  List<ProtectedColumn> findColumns(@Param("objectId") long objectId);

  List<ProtectedColumn> findColumnsByObjectIds(@Param("objectIds") List<Long> objectIds);

  ProtectedColumn findColumnById(@Param("columnId") long columnId);

  ProtectedColumn findColumnByObjectAndName(@Param("objectId") long objectId,
                                            @Param("columnName") String columnName);

  List<DatabaseObjectOption> findDatabaseObjects();

  List<String> findDatabaseColumns(@Param("owner") String owner, @Param("objectName") String objectName);

  long nextObjectId();

  long nextColumnId();

  void insertObject(@Param("objectId") long objectId, @Param("command") ProtectedObjectCreateCommand command);

  void insertColumn(@Param("columnId") long columnId,
                    @Param("objectId") long objectId,
                    @Param("columnName") String columnName,
                    @Param("sensitiveYn") String sensitiveYn,
                    @Param("sensitivityLevel") String sensitivityLevel,
                    @Param("redactionMethod") String redactionMethod);

  int updateColumnPolicy(@Param("columnId") long columnId,
                         @Param("sensitivityLevel") String sensitivityLevel,
                         @Param("redactionMethod") String redactionMethod);

  int updateOrdsPath(@Param("objectId") long objectId, @Param("ordsPath") String ordsPath);

  int updateDescription(@Param("objectId") long objectId, @Param("description") String description);

  int enableObject(@Param("objectId") long objectId);

  int disableObject(@Param("objectId") long objectId);
}
