Package ru.bgcrm.dao

Class ParamValueDAO

java.lang.Object
ru.bgcrm.dao.CommonDAO
ru.bgcrm.dao.ParamValueDAO

public class ParamValueDAO extends CommonDAO
  • Field Details

  • Constructor Details

    • ParamValueDAO

      public ParamValueDAO(Connection con)
    • ParamValueDAO

      public ParamValueDAO(Connection con, boolean history, int userId)
  • Method Details

    • getParamAddress

      public ParameterAddressValue getParamAddress(int id, int paramId, int position) throws SQLException
      Возвращает адресный параметр объекта.
      Parameters:
      id - - код объекта.
      paramId - - param ID.
      position - - позиция, начиная от 1, если в параметре установлены несколько значений.
      Returns:
      Throws:
      SQLException
    • getParamAddress

      public SortedMap<Integer,ParameterAddressValue> getParamAddress(int id, int paramId) throws SQLException
      Возвращает значения адресного параметра объекта.
      Parameters:
      id - - код объекта.
      paramId - - param ID.
      Returns:
      ключ - позиция, значение - значение на позиции.
      Throws:
      SQLException
    • getParamAddressExt

      public SortedMap<Integer,ParameterAddressValue> getParamAddressExt(int id, int paramId, boolean loadDirs) throws SQLException
      Возвращает значения адресного параметра объекта.
      Parameters:
      id - - код объекта.
      paramId - - param ID.
      loadDirs - - признак необходимости загрузить справочники, чтобы был корректно заполнен ParameterAddressValue.getHouse()/
      Returns:
      ключ - позиция, значение - значение на позиции.
      Throws:
      SQLException
    • getParamAddressExt

      public SortedMap<Integer,ParameterAddressValue> getParamAddressExt(int id, int paramId, boolean loadDirs, String formatName) throws SQLException
      Возвращает значения адресного параметра объекта.
      Parameters:
      id - - код объекта.
      paramId - - param ID.
      loadDirs - - признак необходимости загрузить справочники, чтобы был корректно заполнен ParameterAddressValue.getHouse().
      formatName - - наименование формата адреса из конфигурации, с помощью которого форматировать значение адреса.
      Returns:
      ключ - позиция, значение - значение на позиции.
      Throws:
      SQLException
    • getParamFile

      public FileData getParamFile(int id, int paramId, int position) throws SQLException
      Selects values for parameter type 'file'.
      Parameters:
      id - object ID.
      paramId - param ID.
      position - position number for multiple values.
      Returns:
      Throws:
      SQLException
    • getParamFile

      public SortedMap<Integer,FileData> getParamFile(int id, int paramId) throws SQLException
      Selects values for parameter type 'file'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      map with key equals value's position.
      Throws:
      SQLException
    • getParamDate

      public Date getParamDate(int id, int paramId) throws SQLException
      Возвращает значение параметра типа 'date'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamDateTime

      public Date getParamDateTime(int id, int paramId) throws SQLException
      Возвращает значение параметра типа 'datetime'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamText

      public String getParamText(int id, int paramId) throws SQLException
      Selects value of parameter with type 'text'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamBlob

      public String getParamBlob(int id, int paramId) throws SQLException
      Возвращает значение параметра типа 'blob'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamEmail

      public ParameterEmailValue getParamEmail(int id, int paramId, int position) throws SQLException
      Возвращает значение параметра типа 'email'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamEmail

      public SortedMap<Integer,ParameterEmailValue> getParamEmail(int id, int paramId) throws SQLException
      Selects a parameter value with type 'email'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      ключ - позиция значения, значение - данные по параметру.
      Throws:
      SQLException
    • getParamMoney

      public BigDecimal getParamMoney(int id, int paramId) throws SQLException
      Selects a parameter value with type 'money'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      the value or null.
      Throws:
      SQLException
    • getParamPhone

      public ParameterPhoneValue getParamPhone(int id, int paramId) throws SQLException
      Selects a parameter value with type 'phone'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      the value or null.
      Throws:
      SQLException
    • getParamList

      public Set<Integer> getParamList(int id, int paramId) throws SQLException
      Selects a parameter value with type 'list'.
      Parameters:
      id - object ID.
      paramId -
      Returns:
      Set с кодами значений.
      Throws:
      SQLException
    • getParamListWithTitles

      public List<IdTitle> getParamListWithTitles(int id, int paramId) throws SQLException
      Selects a parameter value with type 'list' с наименованиями значений.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamListWithComments

      public Map<Integer,String> getParamListWithComments(int id, int paramId) throws SQLException
      Selects a parameter value with type 'list' с комментариями значений.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      ключ - код значения, значение - комментарий.
      Throws:
      SQLException
    • getParamListWithTitlesAndComments

      public List<IdTitleComment> getParamListWithTitlesAndComments(int id, int paramId) throws SQLException
      Selects a parameter value with type 'list' с наименованиями значений и примечаниями.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamListCountWithTitles

      public List<IdTitle> getParamListCountWithTitles(int id, int paramId) throws SQLException
      Selects a parameter value with type 'listcount' с наименованиями значений.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • getParamListCount

      public Map<Integer,ParameterListCountValue> getParamListCount(int id, int paramId) throws SQLException
      Selects a parameter value with type 'listcount'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      ключ - код значения, значение - доп. данные.
      Throws:
      SQLException
    • getParamTree

      public Set<String> getParamTree(int id, int paramId) throws SQLException
      Selects a parameter value with type 'tree'.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      набор значений.
      Throws:
      SQLException
    • updateParamText

      public void updateParamText(int id, int paramId, String value) throws SQLException
      Устанавливает значение параметра типа 'text'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - значение, null или пустая строка - удалить значение.
      Throws:
      SQLException
    • updateParamBlob

      public void updateParamBlob(int id, int paramId, String value) throws SQLException
      Устанавливает значение параметра типа 'blob'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - значение, null или пустая строка - удалить значение.
      Throws:
      SQLException
    • updateParamEmail

      public void updateParamEmail(int id, int paramId, int position, ParameterEmailValue value) throws SQLException
      Обновляет/добавляет/удаляет значения параметра типа EMail.
      Parameters:
      id - - код сущности в БД.
      paramId - - param ID.
      position - - позиция значения, начинается с 1, 0 - добавить новое значение с позицией MAX+1.
      value - - значение, null - удаление параметра на указанной позиции, если position>0; иначе - удаление всех значений.
      Throws:
      SQLException
    • updateParamList

      public void updateParamList(int id, int paramId, Map<Integer,String> values) throws SQLException
      Устанавливает значения параметра типа 'list' с примечаниями.
      Parameters:
      id - object ID.
      paramId - param ID.
      values - ключ - значение параметра, значение - текстовое примечание.
      Throws:
      SQLException
    • updateParamList

      public void updateParamList(int id, int paramId, Set<Integer> values) throws SQLException
      Устанавливает значения параметра типа 'list' с пустыми примечениями.
      Parameters:
      id - object ID.
      paramId - param ID.
      values - набор с кодами значений.
      Throws:
      SQLException
    • updateParamListCount

      public void updateParamListCount(int id, int paramId, Map<Integer,BigDecimal> values) throws SQLException
      Устанавливает значения параметра типа 'listcount'.
      Parameters:
      id - object ID.
      paramId - param ID.
      values - значения, ключ - код значение, значение - количество.
      Throws:
      SQLException
    • updateParamListCount

      @Deprecated public void updateParamListCount(int id, int paramId, Map<Integer,Double> values, Map<Integer,String> valuesComments) throws SQLException
      Deprecated.
      Использовать updateParamListCount(int, int, Map).
      Throws:
      SQLException
    • updateParamMoney

      public void updateParamMoney(int id, int paramId, BigDecimal value) throws SQLException
      Updates parameter with type 'money'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - the value, when null - remove.
      Throws:
      SQLException
    • updateParamMoney

      public void updateParamMoney(int id, int paramId, String value) throws SQLException
      Updates parameter with type 'money'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - the value, when null - remove.
      Throws:
      SQLException
    • updateParamFile

      public void updateParamFile(int id, int paramId, int position, FileData fileData) throws Exception
      Updates parameter with type 'file'.
      Parameters:
      id - object ID.
      paramId - param ID.
      position - position for multiple values, when is 0 - adding with new positions.
      fileData - value for the given position, if null - removes a value from the position or all values with position == -1.
      Throws:
      Exception
    • updateParamFile

      @Deprecated public void updateParamFile(int id, int paramId, int position, String comment, FileData fileData) throws Exception
      Deprecated.
      Throws:
      Exception
      See Also:
    • updateParamAddress

      public void updateParamAddress(int id, int paramId, int position, ParameterAddressValue value) throws SQLException
      Обновляет/добавляет/удаляет значения адресного параметра.
      Parameters:
      id - - код сущности в БД.
      paramId - - param ID.
      position - - позиция значения, начинается с 1, 0 - добавить новое значение с позицией MAX+1.
      value - - значение, null - удаление параметра на указанной позиции, если position>0; иначе - удаление всех значений.
      Throws:
      SQLException
    • updateParamsAddressOnHouseUpdate

      public void updateParamsAddressOnHouseUpdate(int houseId) throws SQLException
      Обновляет строки адресных параметров для дома. Используется после изменений в адресных справочников, для генерации корректных строк с адресными параметрами.
      Parameters:
      houseId - код дома.
      Throws:
      SQLException
    • updateParamPhone

      public void updateParamPhone(int id, int paramId, ParameterPhoneValue value) throws SQLException
      Устанавливает значения параметра типа 'phone'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - значения, null либо пустой itemList - удаление значения.
      Throws:
      SQLException
    • updateParamDate

      public void updateParamDate(int id, int paramId, Date value) throws SQLException
      Устанавливает значение параметра типа 'date'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - значение, null - удаление.
      Throws:
      SQLException
    • updateParamDateTime

      public void updateParamDateTime(int id, int paramId, Date value) throws SQLException
      Устанавливает значение параметра типа 'datetime'.
      Parameters:
      id - object ID.
      paramId - param ID.
      value - значение, null - удаление.
      Throws:
      SQLException
    • deleteParams

      public void deleteParams(String objectType, int id) throws SQLException
      Удаляет параметры объекта.
      Parameters:
      objectType - тип объекта.
      id - object ID.
      Throws:
      SQLException
    • objectIdInvert

      public void objectIdInvert(String objectType, int currentObjectId) throws SQLException
      Переносит параметры при с кода объекта на -код объекта. Используется при преобразовании не созданного до конца процесса с отрицательным кодом в созданный.
      Parameters:
      objectType -
      currentObjectId -
      Throws:
      SQLException
    • copyParams

      public void copyParams(int fromObjectId, int toObjectId, String copyMapping) throws SQLException, BGException
      Копирует параметры с объекта на другой объект по указанной конфигурации.
      Parameters:
      fromObjectId - исходный объект.
      toObjectId - целевой объект.
      copyMapping - конфигурация.
      Throws:
      SQLException
      BGException
    • copyParams

      public void copyParams(int fromObjectId, int toObjectId, Collection<Integer> paramIds) throws SQLException, BGException
      Копирует параметры с объекта на объект
      Parameters:
      fromObjectId - object ID исходного.
      toObjectId - object ID целевого.
      paramIds - коды параметров.
      Throws:
      SQLException
      BGException
    • copyParam

      public void copyParam(int fromObjectId, int toObjectId, int paramId) throws SQLException, BGException
      Копирует параметр с объекта на объект.
      Parameters:
      fromObjectId - object ID исходного.
      toObjectId - object ID целевого.
      paramId - коды параметра.
      Throws:
      SQLException
      BGException
    • copyParam

      public void copyParam(int fromObjectId, int fromParamId, int toObjectId, int toParamId) throws SQLException, BGException
      Копирует параметр с объекта на объект. Параметры должны быть одного типа.
      Parameters:
      fromObjectId - object ID исходного.
      fromParamId - param ID исходного.
      toObjectId - object ID целевого
      toParamId - param ID целевого.
      Throws:
      SQLException
      BGException
    • isParameterFilled

      public boolean isParameterFilled(int id, Parameter param) throws Exception
      Проверяет заполненость параметра для объекта с кодом id.
      Parameters:
      id - object ID.
      param - параметр.
      Returns:
      Throws:
      Exception
    • parameters

      public Map<Integer,ParameterValuePair> parameters(Id object) throws SQLException
      Loads parameters for Customer, Process, User or AddressHouse.
      Parameters:
      object - customer or process.
      Returns:
      Throws:
      SQLException
    • loadParameters

      public List<ParameterValuePair> loadParameters(List<Parameter> paramList, int id) throws SQLException
      Loads parameter's values.
      Parameters:
      paramList - parameters list.
      id - entity id.
      Throws:
      SQLException
    • loadParameters

      public List<ParameterValuePair> loadParameters(List<Parameter> paramList, int id, boolean offEncryption) throws SQLException
      Loads parameter's values.
      Parameters:
      paramList - parameters list.
      id - entity id.
      offEncryption - decrypt pseudo encrypted values.
      Throws:
      SQLException
    • loadParameterValue

      @Deprecated public void loadParameterValue(ParameterValuePair param, int objectId, boolean offEncription) throws Exception
      Deprecated.
      Throws:
      Exception
    • getParameterAddressValueFromRs

      public static ParameterAddressValue getParameterAddressValueFromRs(ResultSet rs) throws SQLException
      Throws:
      SQLException
    • getParameterAddressValueFromRs

      public static ParameterAddressValue getParameterAddressValueFromRs(ResultSet rs, String prefix) throws SQLException
      Throws:
      SQLException
    • getParameterAddressValueFromRs

      public static ParameterAddressValue getParameterAddressValueFromRs(ResultSet rs, String prefix, boolean loadDirs, String formatName) throws SQLException
      Throws:
      SQLException
    • paramValueFilter

      @Deprecated public boolean paramValueFilter(String expression, int objectId, Map valuesCache) throws SQLException
      Deprecated.
      Фильтр сущности по значению параметра, пока поддерживается только значение вида param::cityId in 1,2,3 param::value in 1,2,3
      Parameters:
      objectId -
      valuesCache -
      equation -
      Returns:
      Throws:
      SQLException
    • getParamJoinFilters

      public static String getParamJoinFilters(String expression, String objectId) throws SQLException
      Добавление INNER JOIN фильтров по параметрам, пока поддерживается только значение вида для списковых. param::value in 1,2,3
      Parameters:
      objectId -
      valuesCache -
      equation -
      Returns:
      Throws:
      SQLException
    • updateParamTree

      public void updateParamTree(int id, int paramId, Set<String> values) throws SQLException
      Изменение значения параметра типа 'tree' объекта.
      Parameters:
      id - object ID.
      paramId - param ID.
      values - значения.
      Throws:
      SQLException
    • getParamTreeWithTitles

      public List<IdStringTitle> getParamTreeWithTitles(int id, int paramId) throws SQLException
      Значения параметра объекта типа 'tree' с текстовыми наименованиями.
      Parameters:
      id - object ID.
      paramId - param ID.
      Returns:
      Throws:
      SQLException
    • searchObjectByParameterPhone

      public Set<Integer> searchObjectByParameterPhone(int parameterId, ParameterPhoneValue parameterPhoneValue) throws SQLException
      Поиск объектов по значениям связанного телефонного параметра
      Parameters:
      parameterId - - ID параметра
      parameterPhoneValue - - набор телефонов для поиска
      Returns:
      Throws:
      SQLException
    • searchObjectByParameterAddress

      public Set<Integer> searchObjectByParameterAddress(int parameterId, ParameterAddressValue parameterAddressValue) throws SQLException
      Функция поиска объектов по значениям связанного адресного параметра
      Parameters:
      parameterId - - ID параметра
      parameterAddressValue - - значение адресного параметра
      Returns:
      Throws:
      SQLException
    • searchObjectByParameterText

      public Set<Integer> searchObjectByParameterText(int parameterId, String parameterTextValue) throws SQLException
      Поиск объектов по значнию текстового параметра.
      Parameters:
      parameterId - param ID.
      parameterTextValue - точное значение.
      Returns:
      список с кодами объектов.
      Throws:
      SQLException
    • searchObjectByParameterList

      public Set<Integer> searchObjectByParameterList(int parameterId, int value) throws Exception
      Searches object IDs by list parameter value.
      Parameters:
      parameterId -
      value -
      Returns:
      Throws:
      Exception
    • getParamPhoneValueItemFromRs

      public static ParameterPhoneValueItem getParamPhoneValueItemFromRs(ResultSet rs) throws SQLException
      Throws:
      SQLException