Tabnine Logo
SIComposite
Code IndexAdd Tabnine to your IDE (free)

How to use
SIComposite
in
org.opensingular.form

Best Java code snippets using org.opensingular.form.SIComposite (Showing top 20 results out of 315)

origin: org.opensingular/singular-form-core

private static void fromMap(Map<String, Content> map, SIComposite instance) {
  for (Map.Entry<String, Content> entry : map.entrySet()) {
    hydrate(instance.getField(entry.getKey()), entry.getValue());
  }
}
origin: org.opensingular/form-core

/**
 * Retorna todos os campos do tipo, instanciando os que ainda não foram.
 *
 * @return instancias dos campos
 */
public List<SInstance> getAllFields() {
  for (SType<?> field : getType().getFields())
    getField(field.getNameSimple());
  return getFields();
}
origin: org.opensingular/singular-form-core

public SCompositeValueSetter set(SType<?> type, Object value) {
  if (value != null) {
    instance.setValue(type, value);
  } else {
    Optional.ofNullable(instance.getField(type)).ifPresent(SInstance::clearInstance);
  }
  return this;
}
origin: org.opensingular/form-core

@Override
Optional<SInstance> getFieldLocalOpt(PathReader pathReader) {
  int fieldIndex = findFieldIndexOpt(pathReader);
  if (fieldIndex != -1) {
    return Optional.of(getField(fieldIndex));
  }
  return Optional.empty();
}
origin: org.opensingular/server-commons

private void copyIdValues(SInstance source, SInstance target) {
  target.setId(source.getId());
  if (source instanceof SIComposite) {
    SIComposite sourceComposite = (SIComposite) source;
    SIComposite targetComposite = (SIComposite) target;
    if (sourceComposite.getFields() != null) {
      for (int i = 0; i < sourceComposite.getFields().size() ; i++) {
        copyIdValues(sourceComposite.getField(i), targetComposite.getField(i));
      }
    }
  } else if (source instanceof SIList) {
    SIList sourceList = (SIList) source;
    SIList targetList = (SIList) target;
    if (sourceList.getChildren() != null) {
      for (int i = 0; i < sourceList.getChildren().size() ; i++) {
        SInstance sourceItem = (SInstance) sourceList.getChildren().get(i);
        SInstance targetItem = (SInstance) targetList.getChildren().get(i);
        copyIdValues(sourceItem, targetItem);
      }
    }
  }
}
origin: org.opensingular/singular-requirement-commons

  @Override
  public STypePdfHealth getType() {
    return (STypePdfHealth) super.getType();
  }
}
origin: org.opensingular/form-core

@Override
public List<SInstance> getChildren() {
  return getFields();
}
origin: org.opensingular/exemplos-form

final Optional<SIList<SIComposite>> lista = ins.findNearest(demonstrativos);
for (int i = 0; i < 5; i++) {
  final SIComposite siComposite = lista.get().addNew();
  siComposite.findNearest(ano).get().setValue(LocalDate.now().getYear() + i);
  final SIList<SIComposite> receitas_ = siComposite.findNearest(receitas).get();
  final SIList<SIComposite> despesas_ = siComposite.findNearest(despesas).get();
  TIPOS_RECEITA.stream().forEach(tipo -> receitas_.addNew().setValue("tipo", tipo));
  TIPOS_DESPESA.stream().forEach(tipo -> despesas_.addNew().setValue("tipo", tipo));
origin: org.opensingular/singular-form-core

@Override
public List<RelationalSQLCommmand> toSQLScript() {
  List<RelationalSQLCommmand> lines = new ArrayList<>();
  for (SType<?> tableContext : targetTables) {
    String tableName = table(tableContext);
    List<Object> params = new ArrayList<>();
    Map<String, Object> containerKeyColumns = new HashMap<>();
    List<RelationalColumn> inserted = insertedColumns(tableName, containerKeyColumns);
    SIComposite tableInstance = instance;
    if (tableContext != tableContext(instance.getType())) {
      Optional<SInstance> found = instance.getFields().stream()
          .filter(field -> tableContext == tableContext(field.getType())).findFirst();
      if (found.isPresent()) {
        tableInstance = (SIComposite) found.get();
      }
    }
    lines.add(new RelationalSQLCommmand(
        "insert into " + tableName + " (" + concatenateColumnNames(inserted, ", ") + ") values ("
            + concatenateColumnValues(inserted, ", ", containerKeyColumns, params) + ")",
        params, tableInstance, inserted));
  }
  return lines;
}
origin: org.opensingular/singular-requirement-commons

private void columnValidation(InstanceValidatable<SIComposite> validatable) {
  Optional<SIBoolean> databaseFieldInstance  = validatable.getInstance().findNearest(foundDataBase);
  Optional<SIBoolean> hibernateFieldInstance = validatable.getInstance().findNearest(foundHibernate);
  // Encontrado no hibernate e nao no banco
  if (hibernateFieldInstance.isPresent()
      && hibernateFieldInstance.get().getValue()
      && databaseFieldInstance.isPresent()
      && !databaseFieldInstance.get().getValue()) {
    validatable.error("Inconsistency between database and Hibernate!");
  }
  else {
    // Encontrado no banco e nao no hibernate
    Optional<SIBoolean>        nullableFieldInstance = validatable.getInstance().findNearest(nullable);
    Optional<SIList<SIString>> listObj               = validatable.getInstance().findNearest(userPrivs);
    List<Object>               listPrivs             = listObj.map(SIList::getValue).orElse(Collections.emptyList());
    List<String>               vals                  = new ArrayList<>();
    listPrivs.forEach(obj -> vals.add((String) obj));
    if (nullableFieldInstance.isPresent() && !nullableFieldInstance.get().getValue() && (!vals.contains("INSERT") || !vals.contains("UPDATE"))) {
      validatable.error("Column NOT NULL without SELECT or UPDATE permissions");
    }
  }
}
origin: org.opensingular/singular-form-core

public SIComposite fillMG(SIComposite MG) {
  MG.setValue(nome, "Minas Gerais");
  MG.setValue(sigla, "MG");
  return MG;
}
origin: org.opensingular/form-core

@Override
public void fillInstance(SInstance ins, T obj) {
  if (!(ins instanceof SIComposite)) {
    throw new SingularFormException("AutoSICompositeConverter somente funciona com instancias compostas.");
  }
  final SIComposite   cins          = (SIComposite) ins;
  final GetterHandler getterHandler = new Mirror().on(obj).get();
  cins.getType().getFields().forEach(f -> cins.setValue(f, getterHandler.field(f.getNameSimple())));
}
origin: org.opensingular/singular-form-core

private SInstance createField(int fieldIndex) {
  SType<?> fieldType = getType().getField(fieldIndex);
  SInstance instance = fieldType.newInstance(getDocument());
  if (fields == null) {
    fields = new FieldMapOfRecordInstance(getType().size());
  }
  fields.set(fieldIndex, instance);
  instance.setParent(this);
  return instance;
}
origin: org.opensingular/form-core

@Override
final <T> T getValueWithDefaultIfNull(PathReader pathReader, Class<T> resultClass) {
  SInstance instance = getFieldLocalWithoutCreating(pathReader);
  if (instance != null) {
    return instance.getValueWithDefaultIfNull(pathReader.next(), resultClass);
  }
  SType<?> tipo = SFormUtil.resolveFieldType(getType(), pathReader);
  return tipo.getAttributeValueOrDefaultValueIfNull(resultClass);
}
origin: org.opensingular/form-wicket

/**
 * property column isolado em outro método para isolar o escopo de
 * serialização do lambda do appendPropertyColumn
 */
private void propertyColumnAppender(BSDataTableBuilder<SInstance, ?, ?> builder,
                  IModel<String> labelModel, IModel<String> sTypeNameModel,
                  IFunction<SInstance, String> displayValueFunction) {
  builder.appendPropertyColumn(labelModel, o -> {
    SIComposite composto = (SIComposite) o;
    SType<?> mtipo = composto.getDictionary().getType(sTypeNameModel.getObject());
    SInstance instancia = composto.findDescendant(mtipo).get();
    return displayValueFunction.apply(instancia);
  });
}
origin: org.opensingular/singular-form-service

@Override
protected void updateInternal(@Nonnull FormKeyLong key, @Nonnull INSTANCE instance, Integer inclusionActor) {
  instance.getDocument().persistFiles();
  formService.update(instance, inclusionActor);
}
origin: org.opensingular/singular-form-core

private boolean isFlatView(FlatViewContext context, SIComposite instance) {
  return instance.asAtr().getLabel() == null || context.isWithoutTitle();
}
origin: org.opensingular/singular-form-core

/**
 * Find a child by the name ({@link SType#getName()})
 * @param parent the parent instance
 * @param childName the complete name of the child {@link SType#getName()}
 * @return the chield
 */
public static Optional<? extends SInstance> findChildByName(@Nonnull SInstance parent, @Nonnull String childName) {
  if(parent instanceof SIComposite) {
    SType<?> sType = parent.getDictionary().getType(childName);
    return ((SIComposite)parent).findDescendant(sType);
  }
  return Optional.empty();
}
origin: org.opensingular/singular-server-commons

private static void copyIdValues(SInstance source, SInstance target) {
  target.setId(source.getId());
  if (source instanceof SIComposite) {
    SIComposite sourceComposite = (SIComposite) source;
    SIComposite targetComposite = (SIComposite) target;
    for (int i = 0; i < sourceComposite.getFields().size() ; i++) {
      copyIdValues(sourceComposite.getField(i), targetComposite.getField(i));
    }
  } else if (source instanceof SIList) {
    SIList sourceList = (SIList) source;
    SIList targetList = (SIList) target;
    if (sourceList.getChildren() != null) {
      for (int i = 0; i < sourceList.getChildren().size() ; i++) {
        SInstance sourceItem = (SInstance) sourceList.getChildren().get(i);
        SInstance targetItem = (SInstance) targetList.getChildren().get(i);
        copyIdValues(sourceItem, targetItem);
      }
    }
  }
}
origin: org.opensingular/singular-form-core

  @Override
  public T getType() {
    return (T) super.getType();
  }
}
org.opensingular.formSIComposite

Most used methods

  • getField
  • getFields
    List only those fields already instantiated. OBS: field instantiation occurs automatically when its
  • getType
  • findNearest
  • getDocument
  • setValue
  • asAtr
  • findDescendant
  • getFieldList
  • asAtrAnnotation
  • asAtrBootstrap
  • clearInstance
  • asAtrBootstrap,
  • clearInstance,
  • createField,
  • findFieldIndex,
  • findFieldIndexOpt,
  • getAllChildren,
  • getAllFields,
  • getDictionary,
  • getFieldLocalWithoutCreating,
  • getFieldOpt

Popular in Java

  • Making http post requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • addToBackStack (FragmentTransaction)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top PhpStorm plugins
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