public String translateImport(SType<?> superType) { String nameFull = superType.getName(); return imports.contains(nameFull) ? superType.getNameSimple() : nameFull; } }
private String mapName(String originalName) { if (originalName.indexOf('.') == -1) { return getName() + '.' + originalName; } return originalName; }
private void prepareDefaultImports(SDictionary dictionary) { for (SType<?> type : dictionary.getType(SType.class).getPackage().getLocalTypes()) { imports.put(type.getNameSimple(), type.getName()); } }
private void initTypeByNameCache(SType<?> rootStype) { STypes .streamDescendants(rootStype, true) .forEach(s -> typeByNameCache.put(s.getName(), s)); }
private void debugAttributesDefined(Appendable appendable, int level) { attributesDefined.getAttributes().stream().filter(att -> !getLocalTypeOptional(att.getNameSimple()) .isPresent()).forEach(att -> { try { pad(appendable, level + 1).append("att ").append(suppressPackage(att.getName())) .append(':').append(suppressPackage(att.getSuperType().getName())).append( att.isSelfReference() ? " SELF" : "").append('\n'); } catch (IOException ex) { LOGGER.log(Level.SEVERE, ex.getMessage(), ex); } }); }
private void debugAttributesDefined(Appendable appendable, int level) { AttributeDefinitionManager.getStaticAttributes(attributesDefined).stream().filter(att -> !getLocalTypeOptional( att.getNameSimple()).isPresent()).forEach(att -> { try { pad(appendable, level + 1).append("att ").append(suppressPackage(att.getName())).append(':').append( suppressPackage(att.getSuperType().getName())).append(att.isSelfReference() ? " SELF" : "") .append('\n'); } catch (IOException ex) { LOGGER.log(Level.SEVERE, ex.getMessage(), ex); } }); }
/** * Adiciona uma coluna cujo conteúdo será o subcampo informado, o titulo da * coluna específico e o conteudo de cada célula será cálculado * dinamicamente mediante a função informada. */ public final SELF col(SType<?> type, String customLabel, IFunction<SInstance, String> displayFunction) { columns.add(new Column(type.getName(), customLabel, displayFunction)); return (SELF) this; }
@Nonnull final AttrInternalRef checkIfIsAttribute() { if (attrInternalRef == null) { throw new SingularFormException("O tipo '" + getName() + "' não é um tipo atributo", this); } return attrInternalRef; }
/** * Returns the nearest instance for the given type or throws an Exception if it is not found. * This method works exactly as the {@link this#findNearest(SType)} * * @param targetType * @param <A> * @return */ @Nonnull public <A extends SInstance> A findNearestOrException(@Nonnull SType<A> targetType) { return findNearest(targetType).orElseThrow(() -> new SingularFormException(String.format("O tipo %s não foi encontrado", targetType.getName()))); }
/** * Registra um atributo que pode ser associado a vários {@link SType} diferentes. */ @Nonnull final AttrInternalRef registerAttribute(@Nonnull SType<?> attr) { AttrInternalRef ref = registerAttribute(attr.getName()); ref.resolve(attr); return ref; }
final void addAttribute(SType<?> attributeDef) { attributeDef.checkIfIsAttribute(); SType<?> owner = attributeDef.getAttributeDefinitionInfo().getOwner(); if (owner != null && owner != this) { throw new SingularFormException( "O Atributo '" + attributeDef.getName() + "' pertence excelusivamente ao tipo '" + owner.getName() + "'. Assim não pode ser reassociado a classe '" + getName(), this); } attributesDefined.add(attributeDef); }
@Nonnull final static SType<?> getAttributeDefinedHierarchy(@Nonnull SType<?> type, @Nonnull AttrInternalRef ref) { Objects.requireNonNull(type); Objects.requireNonNull(ref); for (SType<?> current = type; current != null; current = current.getSuperType()) { SType<?> att = current.getAttributeDefinedLocally(ref); if (att != null) { return att; } } throw new SingularFormException("Não existe atributo '" + ref.getName() + "' em " + type.getName(), type); }
/** * Cria uma mensagem de erro com o path da instância atual acrescido da * mensagem fornecida. */ protected final String errorMsg(String msgToBeAppended) { return "'" + getPathFull() + "' do tipo " + getType().getName() + "(" + getType().getClass().getSimpleName() + ") : " + msgToBeAppended; }
final SType<?> getAttributeDefinedHierarchy(String fullName) { for (SType<?> current = this; current != null; current = current.superType) { SType<?> att = current.getAttributeDefinedLocally(fullName); if (att != null) { return att; } } throw new SingularFormException("Não existe atributo '" + fullName + "' em " + getName(), this); }
protected int getPrefColspan(WicketBuildContext ctx, final SInstance iField) { final SType<?> fieldType = iField.getType(); final HashMap<String, Integer> hintColWidths = ctx.getHint(COL_WIDTHS); String fieldName = fieldType.getName(); return (hintColWidths.containsKey(fieldName)) ? hintColWidths.get(fieldName) : iField.asAtrBootstrap().getColPreference(BSCol.MAX_COLS); }
private SInstance getRootSInstanceForGivenSTypeClass() { SInstance instance = singularWicketTester.getAssertionsInstance().getTarget(); if (instance.getType().getName().equals(SFormUtil.getTypeName(this.sTypeClass))) { return instance; } else { throw new SingularFormException( String.format( "A classe do tipo informado (%s) não corresponde ao tipo encontrado: %s ", SFormUtil.getTypeName(sTypeClass), instance.getType().getName())); } }
private FormTypeEntity getOrCreateNewFormTypeEntity(final SType<?> type) { FormTypeEntity formTypeEntity = formTypeDAO.findFormTypeByAbbreviation(type.getName()); if (formTypeEntity == null) { formTypeEntity = new FormTypeEntity(); formTypeEntity.setAbbreviation(type.getName()); formTypeEntity.setLabel(SFormUtil.getTypeLabel(type.getClass()) .orElse(SFormUtil.getTypeSimpleName((Class<? extends SType<?>>) type.getClass()))); formTypeEntity.setCacheVersionNumber(1L);//TODO VINICIUS.NUNES formTypeDAO.saveOrUpdate(formTypeEntity); } return formTypeEntity; }
private static void writeAttr(ContextArchive ctx, SIPersistenceAttribute attributeArchive, SInstance attribute) { attributeArchive.setAttrType(attribute.getType().getName()); attributeArchive.setAttrValue(attribute.getValue()); } //
final SInstance newAttributeInstanceFor(SType<?> typeToBeAppliedAttribute) { checkIfIsAttribute(); SInstance attrInstance; if (attributeDefinitionInfo.isSelfReference()) { attrInstance = typeToBeAppliedAttribute.newInstance(getDictionary().getInternalDicionaryDocument()); } else { attrInstance = newInstance(getDictionary().getInternalDicionaryDocument()); } attrInstance.setAsAttribute(getName(), this); return attrInstance; }