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

How to use
SInstance
in
org.opensingular.form

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

origin: org.opensingular/singular-form-core

/**
 * Executa as inicilização de atribuição de valor da instância (ver {@link SType#withInitListener(IConsumer)}). Pode
 * sobrepor valores preexistentes.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public final void init() {
  //Não deve chamar o init se estiver no modo de leitura do XML
  if (!getDocument().isRestoreMode()) {
    ((SType) getType()).init(() -> this);
  }
}
origin: org.opensingular/singular-form-wicket

@Override
public String getReadOnlyFormattedText(WicketBuildContext ctx, IModel<? extends SInstance> model) {
  final SInstance mi = model.getObject();
  if (mi != null && mi.getValue() != null) {
    if (mi.asAtr().getDisplayString() != null) {
      return mi.toStringDisplay();
    }
    if (!(mi instanceof SIComposite)) {
      return String.valueOf(mi.getValue());
    }
    return mi.toString();
  }
  return StringUtils.EMPTY;
}
origin: org.opensingular/singular-form-core

private void updateDocumentErrorsSingle(SInstance instance) {
  final SDocument document = instance.getDocument();
  final Integer id = instance.getId();
  final List<ValidationError> errors = contextErrors.get(id);
  document.setValidationErrors(id, errors);
}
origin: org.opensingular/singular-form-core

  public void fromRelationalColumn(Object dbData, SInstance toInstance) {
    if (dbData == null) {
      toInstance.clearInstance();
    } else {
      toInstance.setValue(dbData.toString());
    }
  }
}
origin: org.opensingular/singular-form-core

private void assertCorrectParentRelation(SInstance target) {
  for (SInstance child : target.getChildren()) {
    if (target != child.getParent()) {
      throw new AssertionError(
          "Incossitência Interna: A instância '" + child.getPathFull() + "', filho de '" +
              target.getPathFull() + "', aponta para um outro pai: '" + child.getParent() + "'");
    }
    assertCorrectParentRelation(child);
  }
}
origin: org.opensingular/singular-form-core

private void assertCorrectDocumentReference(@Nonnull SInstance reference, @Nonnull SInstance target) {
  if (reference.getDocument() != target.getDocument()) {
    throw new AssertionError("Inconsitência Interna: O document da instancia '" + target.getPathFull() +
        "' não é o mesmo da instância '" + reference.getPathFull() + "'");
  }
  target.forEachChild(child -> assertCorrectDocumentReference(reference, child));
}
origin: org.opensingular/singular-form-core

@Override
@Nonnull
protected SInstance createNewAttribute(@Nonnull AttrInternalRef ref) {
  SType<?> attributeType = AttributeValuesManagerForSType.getAttributeDefinedHierarchy(getOwner().getType(), ref);
  SInstance instanceAtr = attributeType.newInstance(getOwner().getDocument());
  instanceAtr.setAsAttribute(ref, getOwner());
  return instanceAtr;
}
origin: org.opensingular/singular-form-core

@Nonnull
public static <A extends SType<?>> Optional<SInstance> findAncestor(SInstance node, Class<A> ancestorType) {
  for (SInstance parent = node.getParent(); parent != null; parent = parent.getParent()) {
    if (parent.getType().getClass().equals(ancestorType)) {
      return Optional.of(parent);
    }
  }
  return Optional.empty();
}
origin: org.opensingular/form-service

private SInstance internalLoadSInstance(FormKey key, RefType refType, SDocumentFactory documentFactory,
                    FormVersionEntity formVersionEntity) {
  final SInstance instance     = MformPersistenciaXML.fromXML(refType, formVersionEntity.getXml(), documentFactory);
  final IConsumer loadListener = instance.getAttributeValue(SPackageBasic.ATR_LOAD_LISTENER);
  loadCurrentXmlAnnotationOrEmpty(instance.getDocument(), formVersionEntity);
  instance.setAttributeValue(SPackageFormPersistence.ATR_FORM_KEY, key);
  if (loadListener != null) {
    loadListener.accept(instance);
  }
  return instance;
}
origin: org.opensingular/singular-form-core

@SuppressWarnings("unchecked")
public String getLabel() {
  String label = instance.asAtr().getLabel();
  if (label == null) {
    label = SFormUtil.getTypeLabel((Class<? extends SType<?>>) instance.getType().getClass()).orElse(null);
  }
  if (label == null) {
    label = instance.getName();
  }
  return label;
}
origin: org.opensingular/singular-form-wicket

  @Override
  public void onConfigure(Component component) {
    if (instanceModel.getObject() != null) {
      instanceModel.getObject().getDocument().updateAttributes(null);
    }
  }
}
origin: org.opensingular/singular-form-core

private static void initSubFieldsIfNeeded(@Nonnull SInstance instance) {
  if (hasKeepNodePredicatedInAnyChildren(instance.getType())) {
    //Forces all sub fields in all sub composites to be created just by walking through then
    SInstances.streamDescendants(instance, true).forEach(si -> si.getId());
  }
}
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

/**
 * Criar um XPath para a instância no formato "order[@id=1]/address[@id=4]/street[@id=5]".
 */
private StringBuilder buildXPath(SInstance instance, StringBuilder path) {
  if (instance.getParent() != null) {
    buildXPath(instance.getParent(), path);
  }
  if (path.length() != 0) {
    path.append('/');
  }
  path.append(instance.getName()).append("[@id=").append(instance.getId()).append(']');
  return path;
}
origin: org.opensingular/singular-form-wicket

  @Override
  protected Set<String> update(Set<String> oldClasses) {
    if (model.getObject().getAttributeValue(SPackageBasic.ATR_DEPENDS_ON_FUNCTION) != null) {
      oldClasses.add("dependant-input-group");
    }
    return oldClasses;
  }
});
origin: org.opensingular/singular-form-core

@Override
public I get() {
  if (instance == null && fs != null) {
    instance = (I) FormSerializationUtil.toInstance(fs);
    instance.attachEventCollector();
    /*esse chamada é necessária nesse ponto para atualizar os atributos de visibilidade após a deserialização uma
    * vez que estes não são persistenentes . Talvez a melhor alternativa seja persistir esses valores de atributos*/
    instance.getDocument().updateAttributes(instance.getEventCollector());
    fs = null;
  }
  return instance;
}
origin: org.opensingular/server-commons

protected String createPetitionDescriptionFromForm(SInstance instance) {
  return instance.toStringDisplay();
}
origin: org.opensingular/singular-form-wicket

private <ST extends SType<?>> SInstance resolveTypeFinderInstance(IFunction<T, ST> typeFinder) {
  SInstance instance = getRootSInstanceForGivenSTypeClass();
  ST        subtype  = typeFinder.apply((T) instance.getType());
  return instance.findNearest((SType<SInstance>) subtype).orElse(null);
}
origin: org.opensingular/singular-form-core

public static SInstance tupleKeyRef(SInstance instance) {
  return findAncestor(instance, tableContext(instance.getType())).orElseThrow(() -> new SingularFormException(
      "Relational mapping should provide table name for an ancestor type of the instance '"
          + instance.getName() + "'."));
}
origin: org.opensingular/singular-form-core

/**
 * Encontra a posição de um elemento dentro da lista com o ID informado. Retorna -1 senão encontrar.
 */
private static int findById(Integer instanceId, List<? extends SInstance> list) {
  for (int i = 0; i < list.size(); i++) {
    if (instanceId.equals(list.get(i).getId())) {
      return i;
    }
  }
  return -1;
}
org.opensingular.formSInstance

Most used methods

  • getDocument
    Retorna o documento ao qual pertence a instância atual.
  • getType
  • toStringDisplay
  • getId
    Retorna um ID único dentre as instâncias do mesmo documento. Um ID nunca é reutilizado, mesmo se a i
  • getAttributeValue
  • findNearest
    Returns the nearest SInstance for the given type in the form SInstance tree. The search is performed
  • setId
    Apenas para uso nas soluções de persistencia. Não deve ser usado fora dessa situação.
  • clearInstance
    Apaga os valores associados a instância. Se for uma lista ou composto, apaga os valores em profundid
  • getName
  • getParent
  • getValue
  • isEmptyOfData
    Retorna true se a instancia não conter nenhuma informação diferente de null. A pesquisa é feita em
  • getValue,
  • isEmptyOfData,
  • asAtr,
  • asAtrAnnotation,
  • asAtrProvider,
  • attachEventCollector,
  • detachEventCollector,
  • getDictionary,
  • getField,
  • getPathFromRoot

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Top Vim 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