public void fromRelationalColumn(Object dbData, SInstance toInstance) { if (dbData == null) { toInstance.clearInstance(); } else { toInstance.setValue(dbData.toString()); } } }
public static void restoreState(final SInstance instance, final FormState state) { instance.clearInstance(); hydrate(instance, state.value); }
public static void restoreState(final SInstance instance, final FormState state) { instance.clearInstance(); hydrate(instance, state.value); }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void setObject(T object) { SInstance target = getTarget(); if (target instanceof SIList) { target.clearInstance(); ((List) object).forEach(((SIList) target)::addValue); } else { target.setValue(object); } }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void setObject(T object) { SInstance target = getTarget(); if (target instanceof SIList) { target.clearInstance(); ((List) object).forEach(((SIList) target)::addValue); } else { target.setValue(object); } }
/** Copia os valores de uma instância para outra. Presupõem que as instâncias são do mesmo tipo. */ public static void copyValues(SInstance origin, SInstance target) { target.clearInstance(); hydrate(target, dehydrate(origin)); }
/** Copia os valores de uma instância para outra. Presupõem que as instâncias são do mesmo tipo. */ public static void copyValues(SInstance origin, SInstance target) { target.clearInstance(); hydrate(target, dehydrate(origin)); }
@Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { filterPanel.getInstanceModel().getObject().clearInstance(); form.clearInput(); // filterPanel.getInstanceModel().getObject().init(); target.add(filterPanel); } };
public void fromRelationalColumn(Object dbData, SInstance toInstance) { if (dbData == null) { toInstance.clearInstance(); return; } try { Blob blob = (Blob) dbData; File tempFile = File.createTempFile("blob_" + toInstance.getName(), null); tempFile.deleteOnExit(); try (InputStream input = blob.getBinaryStream(); FileOutputStream output = new FileOutputStream(tempFile)) { IOUtils.copy(input, output); } ((SIAttachment) toInstance).setContent(tempFile.getName(), tempFile, blob.length(), HashUtil.toSHA1Base16(tempFile)); } catch (Exception e) { throw SingularException.rethrow("Error on converting BLOB data to SInstance", e); } } }
@SuppressWarnings("unchecked") public void collectSelectedInstances(SInstance instance, List<Serializable> values, SInstanceConverter converter, List<Object> ids, IFunction<Object, Object> idFunction, List<SInstance> selectedInstances) { for (int i = 0; i < selectedInstances.size(); i += 1) { SInstance ins = selectedInstances.get(i); final Serializable converted = converter.toObject(ins); if (converted != null && !ids.contains(idFunction.apply(converted))) { if (!enableDanglingValues) { if(instance instanceof SIList){ ((SIList) instance).remove(ins); } else { instance.clearInstance(); } } else { values.add(i, converted); } } } }
@Override public void setObject(String key) { if (StringUtils.isEmpty(key)) { getRequestCycle().setMetaData(WicketFormProcessing.MDK_SKIP_VALIDATION_ON_REQUEST, true); getMInstancia().clearInstance(); } else { final Serializable val = getValueFromChace(key).map(TypeaheadCache::getTrueValue).orElse(getValueFromProvider(key).orElse(null)); if (val != null) { instance().asAtrProvider().getConverter().fillInstance(getMInstancia(), val); } else { getMInstancia().clearInstance(); } } }
private static void fromXML(@Nonnull SInstance instance, @Nullable MElement xml) { if (xml == null) return; // Não precisa fazer nada instance.clearInstance(); readAttributes(instance, xml); if (instance instanceof SISimple) { fromXMLSISImple((SISimple<?>) instance, xml); } else if (instance instanceof SIComposite) { fromXMLSIComposite((SIComposite) instance, xml); } else if (instance instanceof SIList) { fromXMLSIList((SIList<?>) instance, xml); } else { throw new SingularFormException( "Conversão não implementando para a classe " + instance.getClass().getName(), instance); } }
public void updateExists() { SInstances.updateBooleanAttribute(this, SPackageBasic.ATR_EXISTS, SPackageBasic.ATR_EXISTS_FUNCTION); if (!exists()) SInstances.visitPostOrder(this, (i, v) -> i.clearInstance()); }
protected void setVallIfNullorClear(String key, SInstance instance) { final Serializable val = getValueFromChace(key).map(TypeaheadCache::getTrueValue).orElse(getValueFromProvider(key).orElse(null)); if (val != null) { instance().asAtrProvider().getConverter().fillInstance(instance, val); } else { instance.clearInstance(); } }
public void updateExists() { SInstances.updateBooleanAttribute(this, SPackageBasic.ATR_EXISTS, SPackageBasic.ATR_EXISTS_FUNCTION); if (!exists()) SInstances.visitPostOrder(this, (i, v) -> i.clearInstance()); }
@Override public void setObject(String key) { if (StringUtils.isEmpty(key)) { getRequestCycle().setMetaData(WicketFormProcessing.MDK_SKIP_VALIDATION_ON_REQUEST, Boolean.TRUE); getSInstance().clearInstance(); } else { setVallIfNullorClear(key, getSInstance()); } } };
private void clearInput(AjaxRequestTarget target) { getModal().hide(target); valueModel.getSInstance().clearInstance(); target.add(valueField); valueField.getBehaviors(AjaxUpdateInputBehavior.class) .forEach(ajax -> ajax.onUpdate(target)); }
@Override public void setObject(Serializable object) { SInstance instance = getSInstance(); if (object == null) { instance.clearInstance(); } else { Optional<SInstanceConverter> converter = resolver.apply(instance); if (converter.isPresent()) { converter.get().fillInstance(instance, object); } else if (instance instanceof SIComposite) { throw new SingularFormException("Nenhum converter foi informado para o tipo " + instance.getName(), instance); } else { instance.setValue(object); } } }
@Override public void setObject(Serializable object) { SInstance instance = getMInstancia(); if (object == null) { instance.clearInstance(); } else { Optional<SInstanceConverter> converter = resolver.apply(instance); if (converter.isPresent()) { converter.get().fillInstance(instance, object); } else if (instance instanceof SIComposite) { throw new SingularFormException("Nenhum converter foi informado para o tipo " + instance.getName(), instance); } else { instance.setValue(object); } } }
/** * Configura os valores contidos em value na MInstancia passara como * parametro recursivamente. Usualmente content é o retorno do metodo * dehydrate. */ public static void hydrate(SInstance instance, Content content) { if (instance != null) { if (instance instanceof SIComposite) { fromMap((Map<String, Content>) content.getRawContent(), (SIComposite) instance); } else if (instance instanceof SISimple) { if (content.getRawContent() == null) { instance.clearInstance(); } else { instance.setValue(content.getRawContent()); } } else if (instance instanceof SIList) { fromList((List<Content>) content.getRawContent(), (SIList) instance); } else { throw new SingularFormException("Tipo de instancia não suportado: " + instance.getClass().getName(), instance); } } }