public static SNode setAttribute(SNode node, IAttributeDescriptor descriptor, SNode value) { Iterable<SNode> oldlist = getAttributes(node, descriptor); if (Sequence.fromIterable(oldlist).isEmpty() && (value != null)) { addAttribute(node, descriptor, value); } else if ((value == null)) { deleteAttribute(node, descriptor, value); } else { if (Sequence.fromIterable(oldlist).count() > 1) { if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( Sequence.fromIterable(oldlist).count() + " nodes match signle value attribute during attribute replacing. Only the first found node replaced."); } if (LOG.isEnabledFor(Level.ERROR)) { LOG.error( " node=" + node.getReference() + "; attribute=" + ((String) BHReflection.invoke( SNodeOperations.asSConcept( SNodeOperations.getConcept(Sequence.fromIterable(oldlist).first())), SMethodTrimmedId.create("getRole", null, "1653mnvAgoG"))) + " (" + Sequence.fromIterable(oldlist).first().getNodeId() + ")"); } } SNodeOperations.replaceWithAnother(Sequence.fromIterable(oldlist).first(), value); descriptor.update(value); } return value; }
public static SNode insertAttribute( SNode node, SNode anchor, IAttributeDescriptor descriptor, SNode value) { // shall insert value *after* anchor if (anchor == null || !(ListSequence.fromList( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute"))) .contains(anchor))) { addAttribute(node, descriptor, value); } else { SNodeOperations.insertNextSiblingChild(anchor, value); } descriptor.update(value); return value; }