public String toString() { return "SD document type '" + docType.getName() + "'"; }
public String getName() { return docType.getName(); } public DataTypeName getDocumentName() { return docType.getDataTypeName(); }
private static Map<String, DocumentType> retrieveDocumentTypes(DocumentTypeManager documentTypeManager) { Map<String, DocumentType> documentTypes = new HashMap<>() ; for (Iterator<DocumentType> i = documentTypeManager.documentTypeIterator(); i.hasNext();) { DocumentType type = i.next(); documentTypes.put(type.getName(), type); } return Collections.unmodifiableMap(documentTypes); }
public String toString() { return "document '" + String.valueOf(docId) + "' of type '" + getDataType().getName() + "'"; }
/** * Check if this document type has the given name, * or inherits from a type with that name. */ public boolean isA(String docTypeName) { if (getName().equalsIgnoreCase(docTypeName)) { return true; } for (DocumentType parent : inherits) { if (parent.isA(docTypeName)) { return true; } } return false; }
private void internalSetId(DocumentId id, DocumentType docType) { if (id != null && id.hasDocType() && docType != null && !id.getDocType().equals(docType.getName())) { throw new IllegalArgumentException("Trying to set a document id (type " + id.getDocType() + ") that doesn't match the document type (" + getDataType().getName() + ")."); } docId = id; }
@SuppressWarnings({ "unchecked" }) @Override public SimpleDocumentAdapter setOutputValue(Expression exp, String fieldName, FieldValue fieldValue) { Field field = output.getField(fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in document type '" + output.getDataType().getName() + "'."); } output.setFieldValue(field, fieldValue); return this; } }
/** * The DocumentUpdate object a processor should work on. The one in args, or schema mapped. * * @return a DocumentUpdate */ private DocumentUpdate configDocUpd(DocumentProcessor proc, DocumentUpdate docU) { if (proc.getFieldMap().isEmpty()) return docU; return new ProxyDocumentUpdate(docU, proc.getDocMap(docU.getDocumentType().getName())); }
/** * Fail if the subtype changes the type of any equally named field. * * @param superType The supertype to verify against * TODO Add strict type checking no duplicate fields are allowed */ private void verifyTypeConsistency(DocumentType superType) { for (Field f : fieldSet()) { Field supField = superType.getField(f.getName()); if (supField != null) { if (!f.getDataType().equals(supField.getDataType())) { throw new IllegalArgumentException("Inheritance type mismatch: field \"" + f.getName() + "\" in datatype \"" + getName() + "\"" + " must have same datatype as in parent document type \"" + superType.getName() + "\""); } } } }
/** * For adding structs defined in document scope * * @param dt The struct to add. * @return self, for chaining */ public SDDocumentType addType(SDDocumentType dt) { NewDocumentType.Name name = new NewDocumentType.Name(dt.getName()); if (getType(name) != null) { throw new IllegalArgumentException("Data type '" + name.toString() + "' has already been used."); } if (name.getName() == docType.getName()) { throw new IllegalArgumentException("Data type '" + name.toString() + "' can not have same name as its defining document."); } ownedTypes.put(name, dt); return this; } public final SDDocumentType getOwnedType(String name) {
public void write(DocumentType type) { byte[] docType = createUTF8CharArray(type.getName()); put(null, docType); putByte(null, ((byte) 0)); putShort(null, (short) 0); // Used to hold the version. Is now always 0. }
public void write(DocumentType type) { byte[] docType = createUTF8CharArray(type.getName()); put(null, docType); putByte(null, ((byte) 0)); putShort(null, (short) 0); // Used to hold the version. Is now always 0. }
@Override public void write(Document document) { buffer = new XmlStream(); buffer.setIndent(indent); optionalWrapperMarker.clear(); write(new Field(document.getDataType().getName(), 0, document.getDataType(), true), document); }
public void write(Document doc) { write(new Field(doc.getDataType().getName(), 0, doc.getDataType(), true), doc); }
public void write(Document doc) { write(new Field(doc.getDataType().getName(), 0, doc.getDataType(), true), doc); }
private Document createConcreteDocument(Document document, ContainerDocumentConfig.Doctype typeConfig) { String componentId = typeConfig.factorycomponent(); // Class name of the factory AbstractConcreteDocumentFactory cdf = docFactoryRegistry.getComponent(new ComponentId(componentId)); if (cdf == null) { log.fine("Unable to get document factory component '" + componentId + "' from document factory registry."); return document; } return cdf.getDocumentCopy(document.getDataType().getName(), document, document.getId()); }
private Document createPutDocument(PutDocumentMessage msg) { Document document = msg.getDocumentPut().getDocument(); String typeName = document.getDataType().getName(); ContainerDocumentConfig.Doctype typeConfig = getDocumentConfig(typeName); if (typeConfig == null) { return document; } return createConcreteDocument(document, typeConfig); }
/** * The Document object the proc should work on. Normally the one in arguments, but could be a proxy object * if schema mapping or @Accesses is in effect. * * <p> * public for testing */ public DocumentPut configDoc(DocumentProcessor docProc, DocumentPut documentPut) { if (!docProc.getFieldMap().isEmpty() || docProc.hasAnnotations()) { Document document = documentPut.getDocument(); document = new ProxyDocument(docProc, document, docProc.getDocMap(document.getDataType().getName())); DocumentPut newDocumentPut = new DocumentPut(document); newDocumentPut.setCondition(documentPut.getCondition()); documentPut = newDocumentPut; } return documentPut; }
@SuppressWarnings("deprecation") public static void printDocumentXml(Document doc, XmlStream xml) { xml.addAttribute("documenttype", doc.getDataType().getName()); xml.addAttribute("documentid", doc.getId()); final java.lang.Long lastModified = doc.getLastModified(); if (lastModified != null) { xml.addAttribute("lastmodifiedtime", lastModified); } doc.getHeader().printXml(xml); doc.getBody().printXml(xml); }
@Override public void write(FieldBase field, Document value) { buffer.beginTag("document"); buffer.addAttribute("documenttype", value.getDataType().getName()); buffer.addAttribute("documentid", value.getId()); final java.lang.Long lastModified = value.getLastModified(); if (lastModified != null) { buffer.addAttribute("lastmodifiedtime", lastModified); } write(null, value.getHeader()); write(null, value.getBody()); buffer.endTag(); }