java.lang.Object
ru.bitel.common.dao.AbstarctDaoConstant
ru.bitel.common.dao.AbstractDao<B>
ru.bitel.common.dao.AbstractIdDao<E>
ru.bitel.oss.kernel.entity.server.bean.AbstractEntityAttrDao<Contract>
ru.bitel.bgbilling.kernel.contract.api.server.bean.ContractDao
All Implemented Interfaces:
AutoCloseable

public class ContractDao extends AbstractEntityAttrDao<Contract>
  • Field Details

  • Constructor Details

    • ContractDao

      public ContractDao(Connection con, int userId)
  • Method Details

    • getEntitySpecDirectory

      public Directory<? extends EntitySpec> getEntitySpecDirectory() throws ru.bitel.bgbilling.common.BGException
      Overrides:
      getEntitySpecDirectory in class AbstractEntityAttrDao<Contract>
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getEntitySpecAttrDirectory

      protected Directory<? extends EntitySpecAttr> getEntitySpecAttrDirectory() throws ru.bitel.bgbilling.common.BGException
      Overrides:
      getEntitySpecAttrDirectory in class AbstractEntityAttrDao<Contract>
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getFromRS

      protected Contract getFromRS(ResultSet rs, boolean loadAttributes) throws SQLException, ru.bitel.bgbilling.common.BGException
      Specified by:
      getFromRS in class AbstractEntityAttrDao<Contract>
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • updateContractParameter

      public boolean updateContractParameter(int contractId, EntityAttr entityAttr) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • deleteContractParameter

      public boolean deleteContractParameter(int entityId, int entitySpecAttrId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • updateContractParameters

      @Deprecated public void updateContractParameters(int contractId, Map<Integer,EntityAttr> entityAttributes) throws ru.bitel.bgbilling.common.BGException
      Deprecated.
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameters

      public Map<Integer,EntityAttr> getContractParameters(int contractId, int paramGroupId) throws ru.bitel.bgbilling.common.BGException
      Возвращает map параметров договора.
      Если параметр не заведен (не указан, не добавлен), то данный параметр будет отсутствовать в результате. Примером может служить параметр типа флаг - отсутствие параметра означает false.
      Parameters:
      contractId - ID договора.
      paramGroupId - ID группы параметров. Если значение >0, то выдаются параметры указанной группы, иначе - все параметры.
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameters

      public Map<Integer,EntityAttr> getContractParameters(int entityId, Set<Integer> entitySpecAttrIds) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterValuesForParameterIds

      public Map<Integer,String> getContractParameterValuesForParameterIds(int contractId, Set<Integer> parameterIds) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameter

      public EntityAttr getContractParameter(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Получение параметра договора.
      Parameters:
      contractId - ID договора
      parameterId - ID параметра
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterText

      public Optional<EntityAttrText> getContractParameterText(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterTextAsString

      public Optional<String> getContractParameterTextAsString(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterDate

      public Optional<EntityAttrDate> getContractParameterDate(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterDate

      public Date getContractParameterDate(int contractId, int parameterId, Date defaultValue) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterBoolean

      public Optional<EntityAttrBoolean> getContractParameterBoolean(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterBoolean

      public Boolean getContractParameterBoolean(int contractId, int parameterId, Boolean defaultValue) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterPhone

      public Optional<EntityAttrPhone> getContractParameterPhone(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterPhoneFirst

      public String getContractParameterPhoneFirst(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterEmail

      public Optional<EntityAttrEmail> getContractParameterEmail(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterEmailFirst

      public String getContractParameterEmailFirst(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterEmailAsString

      public Optional<String> getContractParameterEmailAsString(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterList

      public Optional<EntityAttrList> getContractParameterList(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterListAsString

      public Optional<String> getContractParameterListAsString(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterAddress

      public Optional<EntityAttrAddress> getContractParameterAddress(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractParameterAddressAsString

      public Optional<String> getContractParameterAddressAsString(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getEmailFromContractParameter

      public String getEmailFromContractParameter(int contractId, int parameterId) throws ru.bitel.bgbilling.common.BGException
      Получение строкового представление e-mail параметра.
      В начале пытаемся получить e-mail из TABLE_CONTRACT_PARAMETER_TYPE_EMAIL, если там нет с таким кодом, то возвращаем из TABLE_CONTRACT_PARAMETER_TYPE_STRING, то есть из строкового параметра. Если в email будет несколько - вернутся все через \n.
      Parameters:
      contractId - код договора
      parameterId - параметр
      Returns:
      - строка с e-mail(-ми) или null, если не найден.
      Throws:
      ru.bitel.bgbilling.common.BGException
    • update

      public void update(Contract contract) throws ru.bitel.bgbilling.common.BGException
      Overrides:
      update in class ru.bitel.common.dao.AbstractDao<Contract>
      Throws:
      ru.bitel.bgbilling.common.BGException
    • updateImpl

      protected void updateImpl(Contract contract) throws ru.bitel.bgbilling.common.BGException, SQLException
      Specified by:
      updateImpl in class ru.bitel.common.dao.AbstractDao<Contract>
      Throws:
      ru.bitel.bgbilling.common.BGException
      SQLException
    • updateParameter

      @Deprecated public void updateParameter(int contractId, EntityAttr a) throws ru.bitel.bgbilling.common.BGException
      Deprecated.
      Parameters:
      contractId -
      a -
      Throws:
      ru.bitel.bgbilling.common.BGException
    • updatePassword

      public boolean updatePassword(int contractId, String pswd1, String pswd2, boolean isPswdAuto) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      @Deprecated public List<Contract> list(String title, String comment, int fc, long groupMaskAnd, int firm, List<FilterEntityAttr> entityFilter, boolean subContracts, boolean closed, boolean hidden, Page page) throws ru.bitel.bgbilling.common.BGException
      Parameters:
      title -
      comment -
      fc - -1 - все
      groupMaskAnd - маска групп
      group - = маске групп
      firm - reserved
      entityFilter -
      subContracts - включать ли субдоговора в результат
      closed - включать ли закрытые на текущий момент
      hidden - включать ли скрытые
      page -
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      public List<Contract> list(ContractFilters contractFilters, List<FilterEntityAttr> entityFilter, Page page) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      @Deprecated public List<Contract> list(String title, String comment, int fc, long groupMaskAnd, int firm, List<FilterEntityAttr> entityFilter, boolean subContracts, boolean closed, boolean hidden, String orderBy, Page page) throws ru.bitel.bgbilling.common.BGException
      Parameters:
      title -
      comment -
      fc - -1 - все
      groupMaskAnd - маска групп
      group - = маске групп
      firm - reserved
      entityFilter -
      subContracts - включать ли субдоговора в результат
      closed - включать ли закрытые на текущий момент
      hidden - включать ли скрытые
      page -
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      public List<Contract> list(ContractFilters contractFilters, List<FilterEntityAttr> entityFilter, Page page, Set<Integer> labelIds, boolean inAllLabels) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      public List<Contract> list(ContractFilters contractFilters, List<FilterEntityAttr> entityFilter, String orderBy, Page page) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • list

      public List<Contract> list(ContractFilters contractFilters, List<FilterEntityAttr> entityFilter, String orderBy, Page page, Set<Integer> labelIds, boolean inAllLabels) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContracts

      public List<Contract> getContracts(String idList) throws ru.bitel.bgbilling.common.BGException
      Возвращает список Договоров по строке с кодами договоров, перечисленными через запятую
      Parameters:
      idList -
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getSubContracts

      public List<Contract> getSubContracts(int contractId, int subMode) throws ru.bitel.bgbilling.common.BGException
      Получает зависимые, независимые или все(subMode==-1) субдоговора данного договора.
      Parameters:
      contractId - - код супер договора.
      subMode - зависимый(0), независимый(1)(из KernelConst) или все(-1).
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getByTitle

      public Contract getByTitle(String title) throws ru.bitel.bgbilling.common.BGException
      Возвращает договор по заголовку.
      Parameters:
      title - заголовок.
      Returns:
      договор.
      Throws:
      ru.bitel.bgbilling.common.BGException - ошибка.
    • optByTitle

      public Optional<Contract> optByTitle(String title) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • updatePassword

      public void updatePassword(int contractId, String password) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • addLabelAndDomainFilter

      public static void addLabelAndDomainFilter(StringBuilder where, User user)
    • updateDomain

      public void updateDomain(int contractId, int domainId) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractByTextParameter

      public List<Contract> getContractByTextParameter(int parameterId, String value) throws ru.bitel.bgbilling.common.BGException
      Список договоров у которых заданный текстовый параметр точно совпадает с заданным значением
      Parameters:
      parameterId -
      value -
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractForTextlikeParamValue

      public List<Contract> getContractForTextlikeParamValue(int parameterId, String value)
      Получает договор по текстовому значению/представлению некоторого параметра неопределённого типа. Примерно как ContractParameterManager.getTextlikeParam В отличие от поиска берёт только полноценное совпадение. Работают: текстовые, email, телефон.
    • contractListByFilter

      public String contractListByFilter(ContractFilters contractFilters, List<FilterEntityAttr> entityFilter, Page page) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • checkContractParameter

      public void checkContractParameter(EntityAttr entityAttr) throws ru.bitel.bgbilling.common.BGException
      Throws:
      ru.bitel.bgbilling.common.BGException
    • createFromPattern

      public Contract createFromPattern(ContractCreateData data, boolean inModules) throws Exception
      Создает договор по шаблону
      Parameters:
      pattern_id - номер шаблона
      inModules - проверка в модулях
      userId - код пользователя биллинга
      Returns:
      Throws:
      Exception
    • createFromPattern

      public Contract createFromPattern(ContractCreateData data, Map<String,Object> params, boolean inModules) throws Exception
      Создает договор по шаблону
      Parameters:
      params - дополнительные параметры создания договора для модулей
      inModules - проверка в модулях
      userId - код пользователя биллинга
      Returns:
      Throws:
      Exception
    • checkContractTitleOnDublication

      public boolean checkContractTitleOnDublication(String contractTitle, int contractId)
      Проверка, если в базе договора у которых id<>contractId AND UPPER(title)=contractTirle.toUpperCase()
      Parameters:
      contractTitle - название договора.
      contractId - код договора для которого название проверяться не будет.
      Returns:
      true - если дубликата нет.
    • addSub

      public String addSub(int superId, int subId, int subMode) throws SQLException, ru.bitel.bgbilling.common.BGException
      Добавляет договора в качестве субдоговора в другой договора
      Parameters:
      superId - супердоговор
      subId - субдоговор
      subMode - режим "субирования"
      Returns:
      null - если все успешно, строку с ошибкой - если произошла ошибка
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • updateSuperContractDependSubList

      public void updateSuperContractDependSubList(int superId) throws SQLException
      Обновляет перечень зависимых субдоговоров.
      Parameters:
      superId - код супердоговора
      Throws:
      SQLException
    • freeContract

      public String freeContract(int contractId) throws SQLException, ru.bitel.bgbilling.common.BGException
      Перевод субдоговора в независимый договор
      Parameters:
      contractId - код договора
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • closeContract

      public void closeContract(int contractId) throws SQLException, ru.bitel.bgbilling.common.BGException
      Закрываем период действия договора
      Parameters:
      contractId - код договора
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • closeContract

      public void closeContract(int contractId, int moduleId, int userId) throws SQLException, ru.bitel.bgbilling.common.BGException
      Закрываем период действия договора текущей датой
      Parameters:
      contractId - код договора
      moduleId - код модуля
      userId - идентификатор пользователя
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • closeContract

      public void closeContract(int contractId, int moduleId, int userId, Date date) throws ru.bitel.bgbilling.common.BGException
      Закрываем период действия договора указанной датой
      Parameters:
      contractId - - код договора
      moduleId - - код модуля
      userId - - идентификатор пользователя
      date - - дата закрытия договора
      Throws:
      SQLException
      ru.bitel.bgbilling.common.BGException
    • getContracts

      public List<Contract> getContracts(List<Integer> ids) throws ru.bitel.bgbilling.common.BGException
      Возвращает список Договоров по строке с кодами договоров, перечисленными через запятую
      Parameters:
      idList -
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractsByTitles

      public List<Contract> getContractsByTitles(List<String> titles) throws ru.bitel.bgbilling.common.BGException
      Возвращает договора по списку их номеров.
      Parameters:
      titles - номера договоров
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException
    • getContractIdsByTitles

      public List<Integer> getContractIdsByTitles(List<String> titles) throws ru.bitel.bgbilling.common.BGException
      Возвращает договора по списку их номеров.
      Parameters:
      titles - номера договоров
      Returns:
      Throws:
      ru.bitel.bgbilling.common.BGException