Tabnine Logo
FieldType.getTypeClass
Code IndexAdd Tabnine to your IDE (free)

How to use
getTypeClass
method
in
org.activityinfo.model.type.FieldType

Best Java code snippets using org.activityinfo.model.type.FieldType.getTypeClass (Showing top 18 results out of 315)

origin: bedatadriven/activityinfo

@Override
public String toString() {
  return "FormField{" +
      "id=" + id +
      ", label=" + label +
      ", type=" + type.getTypeClass().getId() +
      '}';
}
origin: bedatadriven/activityinfo

public FieldValue get(ResourceId fieldId, FieldType fieldType) {
  FieldValue value = fieldMap.get(fieldId);
  if(value != null && value.getTypeClass() == fieldType.getTypeClass()) {
    return value;
  } else {
    return null;
  }
}
origin: bedatadriven/activityinfo

public FieldTypeClass getTypeClass() {
  return field.getType().getTypeClass();
}
origin: bedatadriven/activityinfo

@Override
public FieldType resolveResultType(List<FieldType> argumentTypes) {
  checkArity(argumentTypes, 3);
  FieldType conditionType = argumentTypes.get(0);
  if(!(conditionType instanceof BooleanType)) {
    throw new ArgumentException(0, "Expected TRUE/FALSE value");
  }
  FieldType trueType = argumentTypes.get(1);
  FieldType falseType = argumentTypes.get(2);
  if(trueType.getTypeClass() != falseType.getTypeClass()) {
    throw new ArgumentException(2, "Must have the same type as the TRUE argument.");
  }
  return trueType;
}
origin: bedatadriven/activityinfo

@Override
public FieldType resolveResultType(List<FieldType> argumentTypes) {
  //must be unary or binary function
  if(argumentTypes.size() == 1) {
    if(argumentTypes.get(0) instanceof QuantityType) {
      QuantityType t = (QuantityType) argumentTypes.get(0);
      return new QuantityType().setUnits(t.getUnits());
    } else {
      throw new InvalidTypeException("Not Real Valued Argument");
    }
  } else if(argumentTypes.size() == 2) {
    if(argumentTypes.get(0) instanceof QuantityType &&
        argumentTypes.get(1) instanceof QuantityType) {
      QuantityType t1 = (QuantityType) argumentTypes.get(0);
      QuantityType t2 = (QuantityType) argumentTypes.get(1);
      return new QuantityType().setUnits(applyUnits(t1.getUnits(), t2.getUnits()));
    } else {
      throw new InvalidTypeException("Cannot compare types " +
          argumentTypes.get(0).getTypeClass().getId() + " and " +
          argumentTypes.get(1).getTypeClass().getId());
    }
  } else {
    throw new FormulaSyntaxException("The " + getLabel() + "() function expects exactly 1 or 2 argument(s).");
  }
}
origin: bedatadriven/activityinfo

private static FieldValue validateType(FormField field, FieldValue updatedValue) {
  Preconditions.checkNotNull(field);
  if(updatedValue != null) {
    if ( !field.getType().isUpdatable()) {
      throw new InvalidUpdateException(
        format("Field %s ('%s') is a field of type '%s' and its value cannot be set. Found %s",
          field.getId(),
          field.getLabel(),
          field.getType().getTypeClass().getId(),
          updatedValue));
    }
    if (!field.getType().getTypeClass().equals(updatedValue.getTypeClass())) {
      throw new InvalidUpdateException(
        format("Updated value for field %s ('%s') has invalid type. Expected %s, found %s.",
          field.getId(),
          field.getLabel(),
          field.getType().getTypeClass().getId(),
          updatedValue.getTypeClass().getId()));
    }
  }
  return updatedValue;
}
origin: bedatadriven/activityinfo

private FormElement createField(BodyElement element) {
  if(Strings.isNullOrEmpty(element.getLabel())) {
    throw new RuntimeException("Element " + element.getRef() + " has no label");
  }
  InstanceElement instanceElement = instanceElements.get(element.getRef());
  Bind bind = bindings.get(element.getRef());
  FieldType type = createType(element, bind);
  FormField field = new FormField(ResourceId.generateFieldId(type.getTypeClass()));
  field.setCode(buildCode(null, instanceElement).toString());
  field.setLabel(element.getLabel());
  field.setDescription(element.getHint());
  field.setType(type);
  return field;
}
origin: bedatadriven/activityinfo

private FieldTypeClass findTypeFromSchema(Activity activity, ResourceId fieldId) {
  for (ActivityField activityField : activity.getFields()) {
    if(activityField.getResourceId().equals(fieldId)) {
      return activityField.getFormField().getType().getTypeClass();
    }
  }
  return null;
}
origin: bedatadriven/activityinfo

@Override
public FieldValue getValue(TypedFormRecord instance, EvalContext context) {
  FieldValue fieldValue = instance.get(field.getId(), field.getType().getTypeClass());
  if (fieldValue != null) {
    return fieldValue;
  } else {
    // we don't want to get NPE in ComparisonOperator
    if (field.getType() instanceof QuantityType) {
      return new Quantity(0);
    }
    return NullFieldValue.INSTANCE;
  }
}
origin: bedatadriven/activityinfo

  public void updateTypeStyles(FieldTypeClass sourceType) {
    for (Map.Entry<ColumnAction, RadioButton> entry : buttons.entrySet()) {
      final ColumnAction columnAction = entry.getKey();
      if (columnAction instanceof MapExistingAction) {
        final ImportTarget target = ((MapExistingAction) columnAction).getTarget();
        final FieldTypeClass targetType = target.getFormField().getType().getTypeClass();
        final RadioButton button = entry.getValue();

        button.removeStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
        button.removeStyleName(ColumnMappingStyles.INSTANCE.typeMatched());

        if (targetType == sourceType || (sourceType == FieldTypeClass.FREE_TEXT &&
                         targetType == FieldTypeClass.REFERENCE)) {
          button.addStyleName(ColumnMappingStyles.INSTANCE.typeMatched());
        } else {
          button.addStyleName(ColumnMappingStyles.INSTANCE.typeNotMatched());
        }
      }
    }
  }
}
origin: bedatadriven/activityinfo

} else {
  FieldType fieldType = parseFieldType(row);
  FormField newField = addField(formClass, fieldType.getTypeClass(), row);
  newField.setType(fieldType);
  if (newField.getType() instanceof ReferenceType) {
origin: bedatadriven/activityinfo

private void dump(String indent, FormElementContainer container) {
  for(FormElement element : container.getElements()) {
    if(element instanceof FormSection) {
      System.out.println(indent + element.getLabel());
      dump(indent + "   ", ((FormSection) element));
    } else {
      FormField field = ((FormField) element);
      System.out.println(String.format("%s[%s] %s : %s", indent, field.getCode(), field.getLabel(),
          field.getType().getTypeClass().getId()));
    }
  }
}
origin: bedatadriven/activityinfo

public Promise<Void> setValue(TypedFormRecord instance) {
  model.setWorkingRootInstance(instance);
  List<Promise<Void>> tasks = Lists.newArrayList();
  for (FieldContainer container : widgetCreator.getContainers().values()) {
    FormField field = container.getField();
    FieldValue value = model.getWorkingRootInstance().get(field.getId(), field.getType());
    if (value != null && value.getTypeClass() == field.getType().getTypeClass()) {
      tasks.add(container.getFieldWidget().setValue(value));
    } else {
      container.getFieldWidget().clearValue();
    }
    container.setValid();
  }
  return Promise.waitAll(tasks).then(new Function<Void, Void>() {
    @Override
    public Void apply(Void input) {
      relevanceHandler.onValueChange(); // invoke relevance handler once values are set
      return null;
    }
  });
}
origin: bedatadriven/activityinfo

private boolean validateField(FieldContainer container) {
  FormField field = container.getField();
  FieldValue value = getCurrentValue(field);
  if (value != null && value.getTypeClass() != field.getType().getTypeClass()) {
    value = null;
  }
  if (!container.isInputValid()) {
    return false;
  }
  if (!container.getFieldWidget().isValid()) {
    return false;
  }
  Optional<Boolean> validatedBuiltInDates = validateBuiltinDates(container, field);
  if (validatedBuiltInDates.isPresent()) {
    return validatedBuiltInDates.get();
  }
  if (field.isRequired() && isEmpty(value) && field.isVisible() && !container.getFieldWidget().isReadOnly()) { // if field is not visible user doesn't have chance to fix it
    container.setInvalid(I18N.CONSTANTS.requiredFieldMessage());
    return false;
  } else {
    container.setValid();
    return true;
  }
}
origin: bedatadriven/activityinfo

@Override
public JsonValue toJsonObject() {
  JsonValue object = createObject();
  object.put("id", id.asString());
  object.put("code", code);
  object.put("label", label);
  object.put("description", description);
  object.put("relevanceCondition", relevanceConditionExpression);
  object.put("visible", visible);
  object.put("required", required);
  object.put("type", type.getTypeClass().getId());
  if(key) {
    object.put("key", true);
  }
  if(!superProperties.isEmpty()) {
    JsonValue superPropertiesArray = Json.createArray();
    for (ResourceId superProperty : superProperties) {
      superPropertiesArray.add(Json.createFromNullable(superProperty.asString()));
    }
    object.put("superProperties", superPropertiesArray);
  }
  if(type instanceof ParametrizedFieldType) {
    object.put("typeParameters", ((ParametrizedFieldType) type).getParametersAsJson());
  }
  
  return object;
}
origin: bedatadriven/activityinfo

Log.error("Unexpected field type " + type.getTypeClass());
throw new UnsupportedOperationException();
origin: bedatadriven/activityinfo

private void insertIndicatorRow(FormField formField, int sortOrder) {
  SqlInsert insert = SqlInsert.insertInto("indicator");
  insert.value("indicatorId", CuidAdapter.getLegacyIdFromCuid(formField.getId()));
  insert.value("activityId", activityId);
  insert.value("name", formField.getLabel());
  insert.value("nameInExpression", formField.getCode());
  insert.value("description", formField.getDescription());
  if(formField.getType() instanceof QuantityType) {
    insert.value("aggregation",((QuantityType) formField.getType()).getAggregation().ordinal());
  } else {
    insert.value("aggregation",0);
  }
  insert.value("sortOrder", sortOrder);
  insert.value("type", formField.getType().getTypeClass().getId());
  insert.value("mandatory", formField.isRequired());
  
  if(formField.getType() instanceof QuantityType) {
    QuantityType quantityType = (QuantityType) formField.getType();
    insert.value("units", quantityType.getUnits());
  }
  if(formField.getType() instanceof CalculatedFieldType) {
    CalculatedFieldType type = (CalculatedFieldType) formField.getType();
    insert.value("calculatedAutomatically", true);
    insert.value("expression", type.getExpression());
  }
  insert.execute(executor);
}
origin: bedatadriven/activityinfo

private void assertFormClass(FormClass sourceFormClass, FormClass targetFormClass) {
  assertNotEquals(sourceFormClass.getId(), targetFormClass.getId());
  assertEquals(sourceFormClass.getLabel(), targetFormClass.getLabel());
  assertEquals(sourceFormClass.getDescription(), targetFormClass.getDescription());
  // fields
  for (FormField sourceField : sourceFormClass.getFields()) {
    FormField targetField = (FormField) elementByName(targetFormClass.getElements(), sourceField.getLabel());
    assertNotEquals(sourceField.getId(), targetField.getId());
    assertEquals(sourceField.getDescription(), targetField.getDescription());
    assertEquals(sourceField.getCode(), targetField.getCode());
    assertEquals(sourceField.getRelevanceConditionExpression(), targetField.getRelevanceConditionExpression());
    assertEquals(sourceField.getType().getTypeClass(), targetField.getType().getTypeClass());
    // todo
    if (sourceField.getType() instanceof ReferenceType) {
      // need something more sophisticated to check equality of ReferenceType
    } else if (sourceField.getType() instanceof EnumType) {
      // need something more sophisticated to check equality of ReferenceType
    }
  }
  // sections
  for (FormSection sourceSection : sourceFormClass.getSections()) {
    FormSection targetSection = (FormSection) elementByName(targetFormClass.getElements(), sourceSection.getLabel());
    assertNotEquals(sourceSection.getId(), targetSection.getId());
    assertEquals(sourceSection.getLabel(), targetSection.getLabel());
  }
}
org.activityinfo.model.typeFieldTypegetTypeClass

Popular methods of FieldType

  • parseJsonValue
  • accept
  • isUpdatable

Popular in Java

  • Updating database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setRequestProperty (URLConnection)
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Top plugins for Android Studio
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