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

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

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

origin: com.haulmont.charts/charts-web

protected String getDateTimeFormattedValue(Object value, Locale locale) {
  return Datatypes.getNN(Date.class).format(value, locale);
}
origin: com.haulmont.cuba/cuba-rest-api

private static Object parseByDatatype(String value, Class<?> type) throws ParseException {
  Datatype datatype = Datatypes.getNN(type);
  return datatype.parse(value);
}
origin: com.haulmont.cuba/cuba-gui

protected String formatSingleValue(Object v) {
  switch (type) {
    case ENTITY:
      if (v instanceof UUID)
        return v.toString();
      else if (v instanceof Entity)
        return ((Entity) v).getId().toString();
    case ENUM:
      return ((Enum) v).name();
    case RUNTIME_ENUM:
    case DATATYPE:
    case UNARY:
      if (isDateInterval) return (String) v;
      //noinspection unchecked
      Datatype<Object> datatype = Datatypes.getNN(javaClass);
      return datatype.format(v);
    default:
      throw new IllegalStateException("Param type unknown");
  }
}
origin: com.haulmont.bpm/bpm-gui

  @Override
  public Field createField(ProcFormParam formParam, String actExecutionId) {
    DateField dateField = componentsFactory.createComponent(DateField.class);
    standardFieldInit(dateField, formParam);
    setFieldValue(dateField, formParam, Datatypes.getNN(Date.class), actExecutionId);
    return dateField;
  }
}
origin: com.haulmont.bpm/bpm-gui

  @Override
  public Field createField(ProcFormParam formParam, String actExecutionId) {
    CheckBox checkBox = componentsFactory.createComponent(CheckBox.class);
    standardFieldInit(checkBox, formParam);
    setFieldValue(checkBox, formParam, Datatypes.getNN(Boolean.class), actExecutionId);
    return checkBox;
  }
}
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.reports/reports-core

@SuppressWarnings("unchecked")
protected void writeEntity(JsonWriter out, Entity entity) throws IOException {
  out.beginObject();
  Datatype id = Datatypes.getNN(entity.getMetaClass().getPropertyNN("id").getJavaType());
  if (processedObjects.containsKey(entity.getId())) {
    out.name("metaClass");
    out.value(entity.getMetaClass().getName());
    out.name("id");
    out.value(id.format(entity.getId()));
  } else {
    processedObjects.put(entity.getId(), entity);
    out.name("metaClass");
    out.value(entity.getMetaClass().getName());
    out.name("id");
    out.value(id.format(entity.getId()));
    writeFields(out, entity);
  }
  out.endObject();
}
origin: com.haulmont.bpm/bpm-gui

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

  @MetaProperty
  public String getCaption() {
    Locale defaultLocale = AppBeans.get(MessageTools.class).getDefaultLocale();
    String formattedDeploymentDate = Datatypes.getNN(Date.class).format(deploymentDate, defaultLocale);
    return this.name + " (" + this.code + " - " + formattedDeploymentDate + ")";
  }
}
origin: com.haulmont.bpm/bpm-gui

  @Override
  public Field createField(ProcFormParam formParam, String actExecutionId) {
    DateField dateField = componentsFactory.createComponent(DateField.class);
    dateField.setResolution(DateField.Resolution.DAY);
    standardFieldInit(dateField, formParam);
    setFieldValue(dateField, formParam, Datatypes.getNN(java.sql.Date.class), actExecutionId);
    return dateField;
  }
}
origin: com.haulmont.reports/reports-gui

  @Override
  public Field createField(ReportInputParameter parameter) {
    TextField textField = componentsFactory.createComponent(TextField.class);
    textField.addValidator(new DoubleValidator());
    textField.setDatatype(Datatypes.getNN(Double.class));
    return textField;
  }
}
origin: com.haulmont.bpm/bpm-gui

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

@MetaProperty(related = {"snapshotDate,author"})
public String getLabel() {
  String name = "";
  if (author != null && StringUtils.isNotEmpty(this.author.getCaption())) {
    name += this.author.getCaption() + " ";
  }
  Datatype datatype = Datatypes.getNN(Date.class);
  UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
  if (userSessionSource != null && userSessionSource.checkCurrentUserSession()) {
    name += datatype.format(snapshotDate, userSessionSource.getLocale());
  }
  return StringUtils.trim(name);
}
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-global

public KeyValueMetaProperty(MetaClass metaClass, String name, Class javaClass) {
  this.name = name;
  this.javaClass = javaClass;
  this.metaClass = metaClass;
  this.mandatory = false;
  Metadata metadata = AppBeans.get(Metadata.NAME);
  Session metadataSession = metadata.getSession();
  if (Entity.class.isAssignableFrom(javaClass)) {
    range = new ClassRange(metadataSession.getClass(javaClass));
    this.type = Type.ASSOCIATION;
  } else if (EnumClass.class.isAssignableFrom(javaClass)) {
    @SuppressWarnings("unchecked")
    EnumerationImpl enumeration = new EnumerationImpl(javaClass);
    this.range = new EnumerationRange(enumeration);
    this.type = Type.ENUM;
  } else {
    this.range = new DatatypeRange(Datatypes.getNN(javaClass));
    this.type = Type.DATATYPE;
  }
}
origin: com.haulmont.cuba/cuba-gui

  @Override
  public void validate(Object value) throws ValidationException {
    if (value == null)
      return;

    boolean result;
    if (value instanceof String) {
      try {
        Datatype datatype = Datatypes.getNN(java.sql.Date.class);
        UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
        datatype.parse((String) value, sessionSource.getLocale());
        result = true;
      } catch (ParseException e) {
        result = false;
      }
    } else {
      result = value instanceof Date;
    }
    if (!result) {
      String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
      throw new ValidationException(String.format(msg, value));
    }
  }
}
origin: com.haulmont.cuba/cuba-global

protected void writeIdField(Entity entity, JsonObject jsonObject) {
  MetaProperty primaryKeyProperty = metadataTools.getPrimaryKeyProperty(entity.getMetaClass());
  if (primaryKeyProperty == null) {
    primaryKeyProperty = entity.getMetaClass().getProperty("id");
  }
  if (primaryKeyProperty == null)
    throw new EntitySerializationException("Primary key property not found for entity " + entity.getMetaClass());
  if (metadataTools.hasCompositePrimaryKey(entity.getMetaClass())) {
    JsonObject serializedIdEntity = serializeEntity((Entity) entity.getId(), null, Collections.emptySet());
    jsonObject.add("id", serializedIdEntity);
  } else {
    Datatype idDatatype = Datatypes.getNN(primaryKeyProperty.getJavaType());
    jsonObject.addProperty("id", idDatatype.format(entity.getId()));
  }
}
origin: com.haulmont.cuba/cuba-global

public DynamicAttributesMetaProperty(MetaClass metaClass, CategoryAttribute attribute) {
  this.attribute = attribute;
  this.javaClass = DynamicAttributesUtils.getAttributeClass(attribute);
  this.metaClass = metaClass;
  this.name = DynamicAttributesUtils.encodeAttributeCode(attribute.getCode());
  this.mandatory = attribute.getRequired();
  Metadata metadata = AppBeans.get(Metadata.NAME);
  Session metadataSession = metadata.getSession();
  if (Entity.class.isAssignableFrom(javaClass)) {
    range = new ClassRange(metadataSession.getClass(javaClass));
    this.type = Type.ASSOCIATION;
  } else {
    this.range = new DatatypeRange(Datatypes.getNN(javaClass));
    this.type = Type.DATATYPE;
  }
}
origin: com.haulmont.cuba/cuba-gui

@Override
public void init(Map<String, Object> params) {
  super.init(params);
  sessionsTable.setTextSelectionEnabled(true);
  sessionsDs.addCollectionChangeListener(e -> {
    String time = Datatypes.getNN(Date.class).format(sessionsDs.getUpdateTs(), userSessionSource.getLocale());
    lastUpdateTsLab.setValue(time);
  });
  addAction(refreshAction);
}
origin: com.haulmont.cuba/cuba-gui

  @Override
  public void validate(Object value) throws ValidationException {
    if (value == null) {
      return;
    }

    boolean result;
    if (value instanceof String) {
      try {
        Datatype<Double> datatype = Datatypes.getNN(Double.class);
        UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
        Double num = datatype.parse((String) value, sessionSource.getLocale());
        result = checkDoubleOnPositive(num);
      } catch (ParseException e) {
        result = false;
      }
    } else {
      result = (value instanceof Double && checkDoubleOnPositive((Double) value)) || (value instanceof BigDecimal && checkBigDecimalOnPositive((BigDecimal) value));
    }

    if (!result) {
      String msg = message != null ? messages.getTools().loadString(messagesPack, message) : "Invalid value '%s'";
      throw new ValidationException(String.format(msg, value));
    }
  }
}
com.haulmont.chile.core.datatypesDatatypesgetNN

Javadoc

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

Popular methods of Datatypes

  • get
    Get Datatype instance by its unique name
  • getFormatStrings
    Returns localized format strings.
  • getIds
  • getDatatypeRegistry
  • getFormatStringsRegistry

Popular in Java

  • Parsing JSON documents to java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • setContentView (Activity)
  • setScale (BigDecimal)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JFileChooser (javax.swing)
  • JList (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Top 12 Jupyter Notebook extensions
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