Tabnine Logo
Datatypes.get
Code IndexAdd Tabnine to your IDE (free)

How to use
get
method
in
com.haulmont.chile.core.datatypes.Datatypes

Best Java code snippets using com.haulmont.chile.core.datatypes.Datatypes.get (Showing top 20 results out of 315)

origin: com.haulmont.cuba/cuba-rest-api

protected Datatype getDatatype(Class clazz) {
  if (clazz == Integer.TYPE || clazz == Byte.TYPE || clazz == Short.TYPE) return Datatypes.get(Integer.class);
  if (clazz == Long.TYPE) return Datatypes.get(Long.class);
  if (clazz == Boolean.TYPE) return Datatypes.get(Boolean.class);
  return Datatypes.get(clazz);
}
origin: com.haulmont.cuba/cuba-gui

private void loadProperties(Element element, KeyValueContainer container) {
  Element propsEl = element.element("properties");
  if (propsEl != null) {
    for (Element propEl : propsEl.elements()) {
      String name = propEl.attributeValue("name");
      String className = propEl.attributeValue("class");
      if (className != null) {
        container.addProperty(name, ReflectionHelper.getClass(className));
      } else {
        String typeName = propEl.attributeValue("datatype");
        Datatype datatype = typeName == null ? Datatypes.getNN(String.class) : Datatypes.get(typeName);
        container.addProperty(name, datatype);
      }
    }
    String idProperty = propsEl.attributeValue("idProperty");
    if (idProperty != null) {
      if (container.getEntityMetaClass().getProperty(idProperty) == null)
        throw new DevelopmentException(String.format("Property '%s' is not defined", idProperty));
      container.setIdName(idProperty);
    }
  }
}
origin: com.haulmont.cuba/cuba-gui

  public static String formatParamValue(Param param, Object value) {
    //noinspection unchecked
    Datatype datatype = Datatypes.get(param.getJavaClass());
    MetaProperty property = param.getProperty();
    if (property != null) {
      TemporalType tt = (TemporalType) property.getAnnotations().get(MetadataTools.TEMPORAL_ANN_NAME);
      if (tt == TemporalType.DATE) {
        datatype = Datatypes.getNN(java.sql.Date.class);
      }
    }
    if (datatype != null) {
      UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.class);
      return datatype.format(value, userSessionSource.getLocale());
    }
    return value.toString();
  }
}
origin: com.haulmont.cuba/cuba-rest-api

protected Datatype getDatatype(Class clazz) {
  if (clazz == Integer.TYPE || clazz == Byte.TYPE || clazz == Short.TYPE) return Datatypes.get(Integer.class);
  if (clazz == Long.TYPE) return Datatypes.get(Long.class);
  if (clazz == Boolean.TYPE) return Datatypes.get(Boolean.class);
  return Datatypes.get(clazz);
}
origin: com.haulmont.cuba/cuba-gui

private void loadProperties(Element element, ValueDatasource datasource) {
  Element propsEl = element.element("properties");
  if (propsEl != null) {
    for (Element propEl : Dom4j.elements(propsEl)) {
      String name = propEl.attributeValue("name");
      String className = propEl.attributeValue("class");
      if (className != null) {
        datasource.addProperty(name, ReflectionHelper.getClass(className));
      } else {
        String typeName = propEl.attributeValue("datatype");
        Datatype datatype = typeName == null ? Datatypes.getNN(String.class) : Datatypes.get(typeName);
        datasource.addProperty(name, datatype);
      }
    }
    String idProperty = propsEl.attributeValue("idProperty");
    if (idProperty != null) {
      if (datasource.getMetaClass().getProperty(idProperty) == null)
        throw new DevelopmentException(String.format("Property '%s' is not defined", idProperty));
      datasource.setIdName(idProperty);
    }
  }
}
origin: com.haulmont.cuba/cuba-global

public DateDeserializer() {
  dateDatatype = Datatypes.get(Date.class);
}
origin: com.haulmont.cuba/cuba-global

public DateSerializer() {
  dateDatatype = Datatypes.get(Date.class);
}
origin: com.haulmont.cuba/cuba-global

  protected boolean isDatatypeMayBeHidden() {
    if (Strings.isNullOrEmpty(dataTypeName)) return false;
    Datatype datatype = Datatypes.get(dataTypeName);
    return datatype instanceof StringDatatype || datatype instanceof NumberDatatype;
  }
}
origin: com.haulmont.cuba/cuba-gui

  protected void loadDatatype(HasDatatype component, Element element) {
    String datatypeAttribute = element.attributeValue("datatype");
    if (StringUtils.isNotEmpty(datatypeAttribute)) {
      //noinspection unchecked
      component.setDatatype(Datatypes.get(datatypeAttribute));
    }
  }
}
origin: com.haulmont.reports/reports-core

protected Object readSimpleProperty(JsonReader in, Class<?> propertyType) throws IOException {
  String value = in.nextString();
  Object parsedValue = null;
  try {
    Datatype<?> datatype = Datatypes.get(propertyType);
    if (datatype != null) {
      parsedValue = datatype.parse(value);
    }
    return parsedValue;
  } catch (ParseException e) {
    throw new RuntimeException(
        format("An error occurred while parsing property. Class [%s]. Value [%s].", propertyType, value), e);
  }
}
origin: com.haulmont.cuba/cuba-rest-api

/**
 * Parses string value into specific type
 *
 * @param value    value to parse
 * @param typeName Datatype name
 * @return parsed object
 */
public static Object parseByTypename(String value, String typeName) {
  Datatype datatype = Datatypes.get(typeName);
  try {
    return datatype.parse(value);
  } catch (ParseException e) {
    throw new IllegalArgumentException(String.format("Cannot parse specified parameter of type '%s'", typeName), e);
  }
}
origin: com.haulmont.reports/reports-core

@Override
public String convertToString(Class parameterClass, Object paramValue) {
  if (paramValue == null) {
    return null;
  } else if (String.class.isAssignableFrom(parameterClass)) {
    return (String) paramValue;
  } else if (Entity.class.isAssignableFrom(parameterClass)) {
    return EntityLoadInfo.create((Entity) paramValue).toString();
  } else {
    Datatype datatype = Datatypes.get(parameterClass);
    if (datatype != null) {
      return datatype.format(paramValue);
    } else {
      return String.valueOf(paramValue);
    }
  }
}
origin: com.haulmont.reports/reports-core

protected void writeSimpleProperty(JsonWriter out, Entity entity, MetaProperty property) throws IOException {
  Object value = entity.getValue(property.getName());
  if (value != null) {
    out.name(property.getName());
    Datatype datatype = Datatypes.get(property.getJavaType());
    if (datatype != null) {
      out.value(datatype.format(value));
    } else {
      out.value(String.valueOf(value));
    }
  }
}
origin: com.haulmont.bpm/bpm-gui

  @Override
  public Field createField(ProcFormParam formParam, String actExecutionId) {
    TextField textField = componentsFactory.createComponent(TextField.class);
    Datatype datatype = Datatypes.get(Long.class);
    textField.setDatatype(datatype);
    standardFieldInit(textField, formParam);
    setFieldValue(textField, formParam, datatype, actExecutionId);
    return textField;
  }
}
origin: com.haulmont.cuba/cuba-global

  return parsedEnum;
} else {
  Datatype datatype = Datatypes.get(clazz);
  return datatype != null ? datatype.parse(string) : string;
origin: com.haulmont.reports/reports-core

  @Override
  public String format(Object o) {
    if (o != null) {
      Datatype datatype = Datatypes.get(o.getClass());
      if (datatype != null) {
        if (userSessionSource.checkCurrentUserSession()) {
          return datatype.format(o, userSessionSource.getLocale());
        } else {
          return datatype.format(o);
        }
      } else if (o instanceof Enum) {
        return messages.getMessage((Enum) o);
      } else if (o instanceof Instance) {
        return ((Instance) o).getInstanceName();
      } else {
        return String.valueOf(o);
      }
    } else {
      return null;
    }
  }
}
origin: com.haulmont.reports/reports-gui

protected GroupDatasource createDataSource(String dataSetName, List<KeyValueEntity> keyValueEntities, Map<String, Set<Pair<String, Class>>> headerMap) {
  DsBuilder dsBuilder = DsBuilder.create(getDsContext())
      .setId(dataSetName + "Ds")
      .setDataSupplier(getDsContext().getDataSupplier());
  ValueGroupDatasourceImpl ds = dsBuilder.buildValuesGroupDatasource();
  ds.setRefreshMode(CollectionDatasource.RefreshMode.NEVER);
  Set<Pair<String, Class>> headers = headerMap.get(dataSetName);
  for (Pair<String, Class> pair : headers) {
    Class javaClass = pair.getSecond();
    if (Entity.class.isAssignableFrom(javaClass) ||
        EnumClass.class.isAssignableFrom(javaClass) ||
        Datatypes.get(javaClass) != null) {
      ds.addProperty(pair.getFirst(), pair.getSecond());
    }
  }
  dsContext.register(ds);
  keyValueEntities.forEach(ds::includeItem);
  return ds;
}
origin: com.haulmont.cuba/cuba-gui

  @Override
  public void commitAndClose() {
    SessionAttribute item = datasource.getItem();
    if (item.getStringValue() != null) {
      Datatype dt = Datatypes.get(item.getDatatype());
      try {
        Object object = dt.parse(item.getStringValue());
        item.setStringValue(object == null ? "" : object.toString());
      } catch (IllegalArgumentException | ParseException e) {
        showNotification(getMessage("unableToParseValue"), NotificationType.ERROR);
        return;
      }
    }
    super.commitAndClose();
  }
}
origin: com.haulmont.cuba/cuba-core

protected void compileSessionAttributes(UserSession session, Group group) {
  List<SessionAttribute> list = new ArrayList<>(group.getSessionAttributes());
  EntityManager em = persistence.getEntityManager();
  TypedQuery<SessionAttribute> q = em.createQuery("select a from sec$GroupHierarchy h join h.parent.sessionAttributes a " +
      "where h.group.id = ?1 order by h.level desc", SessionAttribute.class);
  q.setParameter(1, group.getId());
  List<SessionAttribute> attributes = q.getResultList();
  list.addAll(attributes);
  for (SessionAttribute attribute : list) {
    Datatype datatype = Datatypes.get(attribute.getDatatype());
    try {
      if (session.getAttributeNames().contains(attribute.getName())) {
        log.warn("Duplicate definition of '{}' session attribute in the group hierarchy", attribute.getName());
      }
      Serializable value = (Serializable) datatype.parse(attribute.getStringValue());
      if (value != null)
        session.setAttribute(attribute.getName(), value);
      else
        session.removeAttribute(attribute.getName());
    } catch (ParseException e) {
      throw new RuntimeException("Unable to set session attribute " + attribute.getName(), e);
    }
  }
}
origin: com.haulmont.reports/reports-core

  @Override
  public Object convertFromString(Class parameterClass, String paramValueStr) {
    if (paramValueStr == null) {
      return null;
    } else if (String.class.isAssignableFrom(parameterClass)) {
      return paramValueStr;
    } else if (Entity.class.isAssignableFrom(parameterClass)) {
      EntityLoadInfo entityLoadInfo = EntityLoadInfo.parse(paramValueStr);
      if (entityLoadInfo != null) {
        return dataManager.load(new LoadContext(entityLoadInfo.getMetaClass()).setId(entityLoadInfo.getId()).setView(View.BASE));
      } else {
        UUID id = UUID.fromString(paramValueStr);
        return dataManager.load(new LoadContext(parameterClass).setId(id).setView(View.BASE));
      }
    } else {
      Datatype datatype = Datatypes.get(parameterClass);
      if (datatype != null) {
        try {
          return datatype.parse(paramValueStr);
        } catch (ParseException e) {
          throw new ReportingException(
              String.format("Couldn't read value [%s] with datatype [%s].",
                  paramValueStr, datatype));
        }
      } else {
        return convertFromStringUnresolved(parameterClass, paramValueStr);
      }
    }
  }
}
com.haulmont.chile.core.datatypesDatatypesget

Javadoc

Get Datatype instance by the corresponding Java class. This method tries to find matching supertype too.

Popular methods of Datatypes

  • getNN
    Get Datatype instance by the corresponding Java class. This method tries to find matching supertype
  • getFormatStrings
    Returns localized format strings.
  • getIds
  • getDatatypeRegistry
  • getFormatStringsRegistry

Popular in Java

  • Finding current android device location
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • scheduleAtFixedRate (Timer)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JFrame (javax.swing)
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now