/** * Adds mapping of the id of a related entity to the given xml mapping, prefixing the id with the given prefix. * * @param xmlMapping Mapping, to which to add the xml. * @param prefix Prefix for the names of properties which will be prepended to properties that form the id. * @param columnNameIterator Iterator over the column names that will be used for properties that form the id. * @param relatedIdMapping Id mapping data of the related entity. */ @SuppressWarnings({"unchecked"}) private void addRelatedToXmlMapping( Element xmlMapping, String prefix, MetadataTools.ColumnNameIterator columnNameIterator, IdMappingData relatedIdMapping) { final Element properties = (Element) relatedIdMapping.getXmlRelationMapping().clone(); MetadataTools.prefixNamesInPropertyElement( properties, prefix, columnNameIterator, true, true ); for ( Element idProperty : (java.util.List<Element>) properties.elements() ) { xmlMapping.add( (Element) idProperty.clone() ); } }
/** * Clones the revision info relation mapping, so that it can be added to other mappings. Also, the name of * the property and the column are set properly. * * @return A revision info mapping, which can be added to other mappings (has no parent). */ private Element cloneAndSetupRevisionInfoRelationMapping() { final Element revMapping = (Element) revisionInfoRelationMapping.clone(); revMapping.addAttribute( "name", verEntCfg.getRevisionFieldName() ); if ( globalCfg.isCascadeDeleteRevision() ) { revMapping.addAttribute( "on-delete", "cascade" ); } MetadataTools.addOrModifyColumn( revMapping, verEntCfg.getRevisionFieldName() ); return revMapping; }
identity = identities.next(); identity.setQName(new QName(identity.getName(), queryElement.getNamespace())); queryElement.add((Element)identity.clone());
@SuppressWarnings({"unchecked"}) private Triple<Element, ExtendedPropertyMapper, String> generateMappingData( PersistentClass pc, EntityXmlMappingData xmlMappingData, AuditTableData auditTableData, IdMappingData idMapper) { final Element classMapping = MetadataTools.createEntity( xmlMappingData.getMainXmlMapping(), auditTableData, pc.getDiscriminatorValue(), pc.isAbstract() ); final ExtendedPropertyMapper propertyMapper = new MultiPropertyMapper(); // Checking if there is a discriminator column if ( pc.getDiscriminator() != null ) { final Element discriminatorElement = classMapping.addElement( "discriminator" ); // Database column or SQL formula allowed to distinguish entity types MetadataTools.addColumnsOrFormulas( discriminatorElement, pc.getDiscriminator().getColumnIterator() ); discriminatorElement.addAttribute( "type", pc.getDiscriminator().getType().getName() ); } // Adding the id mapping classMapping.add( (Element) idMapper.getXmlMapping().clone() ); // Adding the "revision type" property addRevisionType( classMapping, classMapping ); addAdditionalColumns( classMapping ); return Triple.make( classMapping, propertyMapper, null ); }
final Element properties = (Element) idMapping.getXmlRelationMapping().clone(); properties.addAttribute( "name", propertyAuditingData.getName() );
Element endRevMapping = (Element) mappingContext.getRevisionEntityMapping().clone();
keyMapping.add( (Element) cloneAndSetupRevisionInfoRelationMapping().element( "column" ).clone() ); break;
public Object clone() { return element.clone(); }
public Object clone() { return element.clone(); }
public void makeXML(Element rootElement, String filename) { try { //you must detach it for you can add it in the new document after Element rootElementCopied = (Element) rootElement.clone(); Document document = DocumentHelper.createDocument(); document.add(rootElementCopied); writeFile(document, filename); } catch (Exception e){ e.printStackTrace(); } }
public Object clone() { return target().clone(); }
public Object clone() { return target().clone(); }
for (Element row : rows) { int cellIndex = -1; if(row.select("td").hasAttr("rowspan")){ for (Element cell : row.select("td")) { cellIndex++; if (cell.hasAttr("rowspan")) { rowspanCount = Integer.parseInt(cell.attr("rowspan")); cell.removeAttr("rowspan"); Element copyRow = row; for (int i = rowspanCount; i > 1; i--) { nextRow = copyRow.nextElementSibling(); Element cellCopy = cell.clone(); Element childTd = nextRow.child(cellIndex); childTd.after(cellCopy); } } } } }
/** * Clones the revision info relation mapping, so that it can be added to other mappings. Also, the name of * the property and the column are set properly. * * @return A revision info mapping, which can be added to other mappings (has no parent). */ private Element cloneAndSetupRevisionInfoRelationMapping() { final Element revMapping = (Element) revisionInfoRelationMapping.clone(); revMapping.addAttribute( "name", options.getRevisionFieldName() ); if ( options.isCascadeDeleteRevisionEnabled() ) { revMapping.addAttribute( "on-delete", "cascade" ); } MetadataTools.addOrModifyColumn( revMapping, options.getRevisionFieldName() ); return revMapping; }
protected void testElementClone(Element element) throws Exception { Element element2 = (Element) element.clone(); assertTrue("Returned a new Element", element2 != element); assertNull("New element has no parent", element2.getParent()); assertNull("New element has no Document", element2.getDocument()); assertTrue("Element fragments are equal", comparator.compare(element, element2) == 0); } }
public void testElementWithNamespaceClone() { Element element = DocumentFactory.getInstance() .createElement("element"); element.addNamespace("prefix", "uri"); Element clone = (Element) element.clone(); assertNotSame(element, clone); assertNodesEqual(element, clone); }
public void testCloneAttribute() throws Exception { Element root = getRootElement(); root.addAttribute("name", "value"); Attribute attribute = root.attribute("name"); assertTrue(attribute instanceof UserDataAttribute); Element cloned = (Element) root.clone(); Attribute clonedAttribute = cloned.attribute("name"); assertTrue(clonedAttribute instanceof UserDataAttribute); }
public void testAddCloneToOtherElement() { DocumentFactory factory = DocumentFactory.getInstance(); Document doc = factory.createDocument(); Element root = doc.addElement("root"); Element parent1 = root.addElement("parent"); Element child1 = parent1.addElement("child"); Element parent2 = (Element) parent1.clone(); root.add(parent2); assertSame("parent not correct", root, parent2.getParent()); assertSame("document not correct", doc, parent2.getDocument()); Element child2 = parent2.element("child"); assertNotSame("child not cloned", child1, child2); assertSame("parent not correct", parent2, child2.getParent()); assertSame("document not correct", doc, child2.getDocument()); }
public void testSetData() throws Exception { Element root = getRootElement(); assertTrue("Element instanceof UserDataElement", root instanceof UserDataElement); root.setData(userData); assertTrue("Stored user data!", root.getData() == userData); log("root: " + root); assertUserData(root, userData); Element cloned = (Element) root.clone(); assertTrue("Cloned new instance", cloned != root); assertUserData(cloned, userData); cloned = root.createCopy(); assertTrue("Cloned new instance", cloned != root); assertUserData(cloned, userData); }