Package com.linkedin.data.transform

Examples of com.linkedin.data.transform.Instruction


  @Override
  public void interpret(InterpreterContext instrCtx)
  {

    Instruction instruction = instrCtx.getCurrentInstruction();

    if ((!(instruction.getData().getClass() == DataMap.class))
        || (!(instruction.getOperation().getClass() == DataMap.class)))
    {
      instrCtx.addErrorMessage("data and operation in composition instruction have to be of type DataMap, instruction: %1$s",
                      instruction);
    }
    else
    {

      DataMap data = (DataMap) instruction.getData();
      DataMap op = (DataMap) instruction.getOperation();

      Object opWildcard = op.get(FilterConstants.WILDCARD);
      Object dataWildcard = data.get(FilterConstants.WILDCARD);

      if ((opWildcard != null && opWildcard.equals(FilterConstants.NEGATIVE))
View Full Code Here


          data.put(fieldName, FilterConstants.NEGATIVE);
        else
          mergeWith1((DataMap)dataMask, data, fieldName);
      }
      else if (opMask.getClass() == DataMap.class)
        instrCtx.scheduleInstruction(new Instruction((DataMap) opMask,
                                         (DataMap) dataMask,instrCtx.getPath()));
      else
      {
        instrCtx.addErrorMessage("field mask value of unsupported type: %1$s", opMask.getClass().getName());
        failed = true;
View Full Code Here

  @Override
  public void interpret(InterpreterContext instrCtx)
  {
    _instrCtx = instrCtx;

    final Instruction instruction = _instrCtx.getCurrentInstruction();

    final Object dataValue = instruction.getData();
    final DataMap opNode = getOperation(instruction);

    filter(dataValue, opNode);
  }
View Full Code Here

   * Creates and schedules new Instruction for provided data and makes sure they are of
   * proper type. If provided data is not correct, error is added.
   */
  private void scheduleInstruction(DataMap childOperation, DataComplex childData)
  {
    _instrCtx.scheduleInstruction(new Instruction(childOperation, childData, _instrCtx.getPath()));
  }
View Full Code Here

   *
   * @param instrCtx the current interpreter context
   */
  public void interpret(final InterpreterContext instrCtx)
  {
    Instruction instruction = instrCtx.getCurrentInstruction();

    // preconditions:
    // operation's node is always DataMap
    assert instruction.getOperation().getClass() == DataMap.class;
    // data's node is always DataMap
    assert instruction.getData().getClass() == DataMap.class;

    //_usedFields variable is used to keep track of fields, which were already used
    //at this nodes. The reason for it is that if field should not be used in more than
    //one operation e.g. $set and $delete, because such patch becomes ambiguous.
    //Each operation, upon being executed updates this variable.
    final Map<String, String> usedFields = new HashMap<String, String>();

    DataMap opNode = (DataMap) instruction.getOperation();
    DataMap dataNode = (DataMap) instruction.getData();

    /**
     * Apply all supported operations here. _usedFields is used to keep track of fields
     * that operations were applied to.
     */
 
View Full Code Here

            // if patch does data manipulations other than deletes, then we need to
            // create respective branch in data object and continue processing patch
            // on that branch
            dataChild = new DataMap();
            dataNode.put(name, dataChild);
            instrCtx.scheduleInstruction(new Instruction(opChild, (DataMap)dataChild, instrCtx.getPath()));
          }
        }
        else
        {
          // equivalent object exists in data tree
          if (dataChild.getClass() == DataMap.class)
            // if it's of proper type, then create new instruction
            instrCtx.scheduleInstruction(new Instruction(opChild, (DataMap)dataChild, instrCtx.getPath()));
          else
            // incorrect type in data object - it means that patch is
            // incompatible with data
          {
            instrCtx.addErrorMessage("patch incopatible with data object, expected %1$s"
View Full Code Here

TOP

Related Classes of com.linkedin.data.transform.Instruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.