@SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { byte valueType = in.readByte(); switch (valueType) { case 0: value = (T) new Text(); ((Text) value).readFields(in); break; case 1: value = (T) new MarkLogicNode(); ((MarkLogicNode) value).readFields(in); break; case 2: value = (T) new BytesWritable(); ((BytesWritable) value).readFields(in); break; default: throw new IOException("incorrect type"); } type = valueType; }
public MarkLogicNode(ResultItem item) { set(item); }
@Override public void write(DataOutput out) throws IOException { out.writeByte(type); if (value instanceof Text) { ((Text) value).write(out); } else if (value instanceof MarkLogicNode) { ((MarkLogicNode) value).write(out); } else if (value instanceof BytesWritable) { ((BytesWritable) value).write(out); } }
@Override public Content createContent(String uri, ContentCreateOptions options, boolean copyCollections, boolean copyMetadata, boolean copyQuality) throws IOException { if (copyCollections || copyMetadata || copyQuality) { setContentOptions(options, copyCollections, copyMetadata, copyQuality); } return ContentFactory.newContent(uri, getContentAsMarkLogicNode().get(), options); } }
@Override protected boolean nextResult(ResultItem result) { String uri = result.getDocumentURI(); String path = result.getNodePath(); if (currentKey != null) { currentKey.set(uri, path); } else { currentKey = new NodePath(uri, path); } if (currentValue != null) { currentValue.set(result); } else { currentValue = new MarkLogicNode(result); } return true; }
@Override public void write(NodePath path, MarkLogicNode record) throws IOException, InterruptedException { if (record == null || record.get() == null) { throw new UnsupportedOperationException("Record node is null."); } else if (record.get().getNodeType() != Node.ELEMENT_NODE) { throw new UnsupportedOperationException("Unsupported node type: " + record.get().getNodeType()); String recordString = record.toString();
@Override public MarkLogicNode getContentAsMarkLogicNode() { return new MarkLogicNode(doc); }
@Override public void write(DocumentURI uri, MarkLogicNode record) throws IOException, InterruptedException { // initialize recordString String recordString = record == null ? "()" : record.toString(); // execute query Session session = getSession(); try { AdhocQuery request = session.newAdhocQuery(query); request.setNewStringVariable(DOCURI_VARIABLE_NAME, InternalUtilities.unparse(uri.getUri())); request.setNewVariable(NODE_VARIABLE_NAME, ValueType.ELEMENT, recordString); session.submitRequest(request); commitIfNecessary(); } catch (RequestException e) { LOG.error(e); LOG.error(query); throw new IOException(e); } }
} else if (value instanceof MarkLogicNode) { content = ContentFactory.newContent(uri, ((MarkLogicNode) value).get(), options); } else if (value instanceof BytesWritable) { content = ContentFactory.newContent(uri,
public MarkLogicNode getContentAsMarkLogicNode() { if (contentType == ContentType.XML || contentType == ContentType.TEXT) { return new MarkLogicNode(getContentAsText().toString(), contentType); } throw new UnsupportedOperationException( "Cannot convert JSON or binary data to MarkLogicNode."); }
@SuppressWarnings("unchecked") @Override public void readFields(DataInput in) throws IOException { String fn = Text.readString(in); fileName = fn; byte valueType = in.readByte(); switch (valueType) { case 0: value = (VALUE) new Text(); ((Text) value).readFields(in); break; case 1: value = (VALUE) new MarkLogicNode(); ((MarkLogicNode) value).readFields(in); break; case 2: value = (VALUE) new BytesWritable(); ((BytesWritable) value).readFields(in); break; default: throw new IOException("incorrect type"); } type = valueType; }
} else if (value instanceof MarkLogicNode) { content = ContentFactory.newContent(uri, ((MarkLogicNode) value).get(), options); } else if (value instanceof BytesWritable) { content = ContentFactory.newContent(uri,
@Override public void write(DataOutput out) throws IOException { Text.writeString(out, fileName); out.writeByte(type); if (value instanceof Text) { ((Text) value).write(out); } else if (value instanceof MarkLogicNode) { ((MarkLogicNode) value).write(out); } else if (value instanceof BytesWritable) { ((BytesWritable) value).write(out); } }
result.getValueType() == ValueType.ATTRIBUTE || result.getValueType() == ValueType.TEXT)) { ((MarkLogicNode)value).set(result); } else if (valueClass.equals(DatabaseDocument.class)) { ((DatabaseDocument) value).set(result);
break; case 1: value = (VALUE) new MarkLogicNode(); ((MarkLogicNode) value).readFields(in); break; case 2:
return ValueFactory.newValue(valueType, ((DoubleWritable)value).get()); } else if (value instanceof MarkLogicNode) { return ValueFactory.newValue(valueType, ((MarkLogicNode)value).get()); } else { throw new UnsupportedOperationException("Value " +
@Override public void write(DataOutput out) throws IOException { if (graphUri == null) { out.writeByte(0); } else { out.writeByte(1); Text t = new Text(graphUri); t.write(out); } out.writeByte(type); if (value instanceof Text) { ((Text) value).write(out); } else if (value instanceof MarkLogicNode) { ((MarkLogicNode) value).write(out); } else if (value instanceof BytesWritable) { ((BytesWritable) value).write(out); } //serialize permissions if (permissions == null) { out.writeByte(0); } else { out.writeByte(permissions.length); for(int i=0; i<permissions.length; i++) { Text role = new Text(permissions[i].getRole()); Text cap = new Text(permissions[i].getCapability().toString()); role.write(out); cap.write(out); } } }
((MarkLogicNode)value).get(), options); } else if (value instanceof ForestDocument) { ContentCreateOptions newOptions = options;