/** * For updates a separate translation record is required. * The output row is used for this. */ @Override public Record createOutputRecord(EISInteraction interaction, AbstractRecord translationRow, EISAccessor accessor) { if (((interaction.getInteractionSpec() != null) && ((MongoInteractionSpec)interaction.getInteractionSpec()).getOperation() == MongoOperation.UPDATE) || ((interaction.getProperty(OPERATION) != null) && ((interaction.getProperty(OPERATION) == MongoOperation.UPDATE) || (interaction.getProperty(OPERATION).equals(MongoOperation.UPDATE.name()))))) { return (Record)interaction.createRecordElement(interaction.getInputRecordName(), translationRow, accessor); } else { return null; } }
/** * Set the default record name from the descriptor. */ public void prepare(AbstractSession session) { if (getInputRecordName().length() == 0) { if ((getQuery() != null) && (getQuery().getDescriptor() instanceof EISDescriptor)) { EISDescriptor descriptor = (EISDescriptor)getQuery().getDescriptor(); setInputRecordName(descriptor.getDataTypeName()); } else { setInputRecordName("input"); } } super.prepare(session); }
/** * PUBLIC: * Define the output argument to the interaction and the field/argument name to be substitute for it. * This is only required if an output row is not used. * The parameterAndArgumentFieldName is the name of the output record argument expected, * and is the field or argument name to be used to be used for it. * These names are assumed to be the same, if not this method can be called with two arguments. */ public void addOutputArgument(String parameterAndArgumentFieldName) { addOutputArgument(parameterAndArgumentFieldName, parameterAndArgumentFieldName); }
/** * PUBLIC: * Returns the adapter property associated the given name. * If the interaction is associated with a query that has a descriptor, * The descriptor's properties are automatically inherited. */ public Object getProperty(String name) { Object value = getProperties().get(name); // Check descriptor property if available. if ((value == null) && (getQuery() != null) && (getQuery().getDescriptor() != null)) { value = getQuery().getDescriptor().getProperty(name); } return value; }
StringWriter writer = new StringWriter(); writer.write("Executing "); writer.write(toString()); writer.write(Helper.cr()); writer.write("\tspec => "); writer.write(String.valueOf(getInteractionSpec())); writer.write(Helper.cr()); writer.write("\tproperties => "); writer.write(String.valueOf(getProperties())); writer.write(Helper.cr()); writer.write("\tinput => ["); if (!getParameters().isEmpty()) { for (Iterator iterator = getParameters().iterator(); iterator.hasNext();) { Object parameter = iterator.next(); writer.write(String.valueOf(parameter)); writer.write(String.valueOf(getInputRow())); writer.write("]");
/** * Arguments to the interaction can be passed two ways. * The entire argument row can be converted to the input record, * or the arguments from the row can be translated into the interaction parameters. */ public void translate(AbstractRecord translationRow, AbstractRecord modifyRow, AbstractSession session) { if (modifyRow != null) { // Avoid clearing a prepared row. setInputRow(modifyRow); } if (hasArguments()) { List parametersValues = new ArrayList(getArguments().size()); for (int index = 0; index < getArguments().size(); index++) { Object argument = getArguments().elementAt(index); // The argument is either a value or a databasefield that needs to be translated. if ((argument != null) && (argument instanceof DatabaseField)) { DatabaseField field = (DatabaseField)argument; Object value = translationRow.get(field); //BUG#12345:modifyRow is null for reads if ((value == null) && (modifyRow != null)) { value = modifyRow.get(field); } parametersValues.add(value); } else { parametersValues.add(argument); } } setParameters(parametersValues); } }
session.startOperationProfile(SessionProfiler.SqlPrepare, eisCall.getQuery(), SessionProfiler.ALL); Record input = null; Record output = null; output = getEISPlatform().createOutputRecord(eisCall, translationRow, this); } finally { session.endOperationProfile(SessionProfiler.SqlPrepare, eisCall.getQuery(), SessionProfiler.ALL); session.startOperationProfile(SessionProfiler.StatementExecute, eisCall.getQuery(), SessionProfiler.ALL); try { boolean success = true; if (eisCall.isNothingReturned()) { if (success) { result = Integer.valueOf(1); AbstractRecord outputRow = getEISPlatform().buildRow(output, eisCall, this); if (outputRow != null) { eisCall.getQuery().setProperty("output", outputRow); if (session.hasEventManager()) { session.getEventManager().outputParametersDetected(outputRow, eisCall); } else if (eisCall.isOneRowReturned()) { result = getEISPlatform().buildRow(output, eisCall, this); } else { session.endOperationProfile(SessionProfiler.StatementExecute, eisCall.getQuery(), SessionProfiler.ALL);
Object element = indexedRecord.get(index); if (element instanceof Record) { rows.addElement(buildRow((Record)element, accessor)); } else { rows.add(buildRow(record, accessor)); return rows; if (getOutputResultPath().length() > 0) { Object element = mappedRecord.get(getOutputResultPath()); return buildRows((IndexedRecord)element, accessor); } else if (element instanceof MappedRecord) { mappedRecord = (MappedRecord)element; Object elementValue = elements.get(index); if (elementValue instanceof Record) { rows.addElement(buildRow((Record)elementValue, accessor)); } else { rows.add(elementValue);
InteractionSpec spec = interaction.getInteractionSpec(); if (spec == null) { NamespaceResolver namespaceResolver = null; try { namespaceResolver = ((EISDescriptor)interaction.getQuery().getDescriptor()).getNamespaceResolver(); } catch (Exception e) { fileSpec.setFileName((String)interaction.getProperty(FILE_NAME)); fileSpec.setXPath((String)interaction.getProperty(XPATH)); fileSpec.setXQuery((String)interaction.getProperty(XQUERY)); fileSpec.setDOM((Element)interaction.getProperty(DOM)); if (interaction.getQuery().isDeleteObjectQuery()) { fileSpec.setInteractionType(XMLFileInteractionSpec.DELETE); } else if (interaction.getQuery().isInsertObjectQuery()) { fileSpec.setInteractionType(XMLFileInteractionSpec.INSERT); } else if (interaction.getQuery().isModifyQuery()) { fileSpec.setInteractionType(XMLFileInteractionSpec.UPDATE); } else if (interaction.getQuery().isReadQuery()) { fileSpec.setInteractionType(XMLFileInteractionSpec.READ);
InteractionSpec spec = interaction.getInteractionSpec(); if (spec == null) { CciJMSInteractionSpec jmsSpec; if (interaction.getProperty(MODE) == null) { throw EISException.propertyNotSet(MODE); if (interaction.getProperty(MODE).equals(SEND)) { jmsSpec = new CciJMSSendInteractionSpec(); } else if (interaction.getProperty(MODE).equals(RECEIVE)) { jmsSpec = new CciJMSReceiveInteractionSpec(); } else if (interaction.getProperty(MODE).equals(SEND_RECEIVE)) { jmsSpec = new CciJMSSendReceiveInteractionSpec(); } else { property = (String)interaction.getProperty(SELECTOR); if (property != null) { jmsSpec.setMessageSelector(property); property = (String)interaction.getProperty(DESTINATION_URL); if (property != null) { jmsSpec.setDestinationURL(property); } else { property = (String)interaction.getProperty(DESTINATION); if (property != null) { jmsSpec.setDestination(property); property = (String)interaction.getProperty(REPLY_TO_DESTINATION_URL); if (property != null) {
InteractionSpec spec = interaction.getInteractionSpec(); if (spec == null) { MongoInteractionSpec mongoSpec = new MongoInteractionSpec(); Object operation = interaction.getProperty(OPERATION); if (interaction.isQueryStringCall()) { mongoSpec.setCode(((QueryStringCall)interaction).getQueryString()); operation = MongoOperation.EVAL; Object collection = interaction.getProperty(COLLECTION); if (collection != null) { mongoSpec.setCollection((String)collection); Object preference = interaction.getProperty(READ_PREFERENCE); if (preference instanceof ReadPreference) { mongoSpec.setReadPreference((ReadPreference)preference); Object concern = interaction.getProperty(WRITE_CONCERN); if (concern instanceof WriteConcern) { mongoSpec.setWriteConcern((WriteConcern)concern); Object options = interaction.getProperty(OPTIONS); if (options instanceof Number) { mongoSpec.setOptions(((Number)options).intValue()); Object skip = interaction.getProperty(SKIP); if (skip instanceof Number) { mongoSpec.setSkip(((Number)skip).intValue()); Object limit = interaction.getProperty(LIMIT);
/** * Allow the platform to build the interaction spec based on properties defined in the interaction. */ public InteractionSpec buildInteractionSpec(EISInteraction interaction) { return interaction.getInteractionSpec(); }
List elements = new Vector(values.size()); for (int index = 0; index < values.size(); index++) { elements.add(createRecordElement(elementName, values.get(index), accessor)); keysIterator.hasNext();) { DatabaseField field = (DatabaseField)keysIterator.next(); Object elementValue = createRecordElement(field.getName(), valuesRow.get(field), accessor); accessor.getEISPlatform().setValueInRecord(field.getName(), elementValue, record, accessor);
/** * The arguments are the values in order of occurance in the record. */ public Vector getArguments() { return super.getArguments(); }
/** * Allow the platform to handle record to row conversion. */ public Vector buildRows(Record record, EISInteraction interaction, EISAccessor accessor) { Record output = record; if (getRecordConverter() != null) { output = getRecordConverter().converterFromAdapterRecord(output); } return interaction.buildRows(output, accessor); }
/** * Allow the platform to create the appropiate type of record for the interaction. */ public Record createInputRecord(EISInteraction interaction, EISAccessor accessor) { Record input = interaction.createInputRecord(accessor); if (getRecordConverter() != null) { input = getRecordConverter().converterToAdapterRecord(input); } return input; }
/** * INTERNAL: * Allow the platform to handle record to row conversion. */ public AbstractRecord buildRow(Record record, EISInteraction interaction, EISAccessor accessor) { Record output = record; if (getRecordConverter() != null) { output = getRecordConverter().converterFromAdapterRecord(output); } return interaction.buildRow(output, accessor); }
public String toString() { return Helper.getShortClassName(getClass()) + "(" + getFunctionName() + ")"; } }
StringWriter writer = new StringWriter(); writer.write("Executing "); writer.write(toString()); writer.write(Helper.cr()); writer.write("\tspec => "); writer.write(String.valueOf(getInteractionSpec())); writer.write(Helper.cr()); writer.write("\tproperties => "); writer.write(String.valueOf(getProperties())); writer.write(Helper.cr()); writer.write("\tinput => ["); if (!getParameters().isEmpty()) { for (Iterator iterator = getParameters().iterator(); iterator.hasNext();) { Object parameter = iterator.next(); writer.write(String.valueOf(parameter)); writer.write(String.valueOf(getInputRow())); writer.write("]");
/** * Arguments to the interaction can be passed two ways. * The entire argument row can be converted to the input record, * or the arguments from the row can be translated into the interaction parameters. */ public void translate(AbstractRecord translationRow, AbstractRecord modifyRow, AbstractSession session) { setInputRow(modifyRow); if (hasArguments()) { Vector parametersValues = new Vector(getArguments().size()); for (int index = 0; index < getArguments().size(); index++) { Object argument = getArguments().elementAt(index); // The argument is either a value or a databasefield that needs to be translated. if ((argument != null) && (argument instanceof DatabaseField)) { DatabaseField field = (DatabaseField)argument; Object value = translationRow.get(field); //BUG#12345:modifyRow is null for reads if ((value == null) && (modifyRow != null)) { value = modifyRow.get(field); } parametersValues.addElement(value); } else { parametersValues.addElement(argument); } } setParameters(parametersValues); } }