@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final SubDocument other = (SubDocument) obj; if (this.documentId != other.documentId) { return false; } if (this.index != other.index) { return false; } if (this.values != other.values && (this.values == null || !this.values.equals(other.values))) { return false; } if (this.type != other.type && (this.type == null || !this.type.equals(other.type))) { return false; } return true; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (getClass() != obj.getClass()) { return false; } final DocStructure other = (DocStructure) obj; if (!this.type.equals(other.type)) { return false; } if (this.index != other.index) { return false; } if (!this.elements.equals(other.elements)) { return false; } return true; }
public void setSubDoc(SubDocument subdoc) throws IllegalArgumentException { if (!table.getSubDocType().equals(subdoc.getType())) { throw new IllegalArgumentException("Type of table " + table + " is " + table.getSubDocType() + " which is " + "different than the type of the given subdocument (" + subdoc.getType() + ")"); } for (String key : subdoc.getType().getAttributeKeys()) { String fieldName = table.subDocHelper().toColumnName(key); //@gortiz: I think we can not use types here! Field f = field(fieldName); ScalarValue<?> v = subdoc.getValue(key); setValue(f, v); } }
SubDocType type2 = structure2.getType(); if (!type1.equals(type2)) { Collection<SubDocAttribute> attributes1 = type1.getAttributes(); Collection<SubDocAttribute> attributes2 = type2.getAttributes();
docCounter++; assert subDocument.getType().equals(type);
@Override public void insertSubdocuments(String collection, SubDocType type, Iterable<? extends SubDocument> subDocuments) { try { SubDocTable table = meta.getCollectionSchema(collection).getSubDocTable(type); InsertSetMoreStep<?> insert = null; for (SubDocument subDocument : subDocuments) { assert subDocument.getType().equals(type); SubDocTableRecord record = new SubDocTableRecord(table, subDocTypeBuilderProvider); record.setDid(subDocument.getDocumentId()); record.setIndex(translateSubDocIndexToDatabase(subDocument.getIndex())); record.setSubDoc(subDocument); if (insert == null) { insert = dsl.insertInto(table).set(record); } else { insert = insert.newRecord().set(record); } } if (insert != null) { insert.execute(); } else { assert false : "Call to insertSubdocuments with an empty set of subdocuments"; LOGGER.warn("Call to insertSubdocuments with an empty set of subdocuments"); } } catch (DataAccessException ex) { //TODO: Change exception throw new RuntimeException(ex); } }