private List<String> rebuildAttributes(SimpleFeatureType sft) { Layer layer = applicationLayer.getService().getSingleLayer(applicationLayer.getLayerName()); List<String> attributesToRetain = new ArrayList<String>(); for (AttributeDescriptor ad : sft.getAttributes()) { String name = ad.getName(); String fullName = sft.getId() + ":" + name; // if attribute already added return. if (attributesToRetain.contains(fullName)) { return attributesToRetain; } attributesToRetain.add(fullName); // Used for display in JSP if (StringUtils.isNotBlank(ad.getAlias())) { attributeAliases.put(fullName, ad.getAlias()); } if (applicationLayer.getAttribute(sft, name) == null) { ConfiguredAttribute ca = new ConfiguredAttribute(); // default visible if not geometry type // and not a attribute of a related featuretype boolean defaultVisible = true; if (layer.getFeatureType().getId() != sft.getId() || AttributeDescriptor.GEOMETRY_TYPES.contains(ad.getType())) { defaultVisible = false; } ca.setVisible(defaultVisible); ca.setAttributeName(name); ca.setFeatureType(sft); applicationLayer.getAttributes().add(ca); Stripersist.getEntityManager().persist(ca); if (!"save".equals(getContext().getEventName())) { String message = "Nieuw attribuut \"{0}\" gevonden in "; if (layer.getFeatureType().getId() != sft.getId()) { message += "gekoppelde "; } message += "attribuutbron"; if (layer.getFeatureType().getId() == sft.getId()) { message += ": wordt zichtbaar na opslaan"; } getContext().getMessages().add(new SimpleMessage(message, name)); } } } if (sft.getRelations() != null) { for (FeatureTypeRelation rel : sft.getRelations()) { attributesToRetain.addAll(rebuildAttributes(rel.getForeignFeatureType())); } } return attributesToRetain; }