Extracts assignment baseline data.

@param assignment xml assignment
@param mpx mpxj assignment
422729
private void readAssignmentBaselines(Project.Assignments.Assignment assignment, ResourceAssignment mpx)
   {
      for (Project.Assignments.Assignment.Baseline baseline : assignment.getBaseline())
      {
         int number = NumberHelper.getInt(baseline.getNumber());

         //baseline.getBCWP()
         //baseline.getBCWS()
         Number cost = DatatypeConverter.parseExtendedAttributeCurrency(baseline.getCost());
         Date finish = DatatypeConverter.parseExtendedAttributeDate(baseline.getFinish());
         //baseline.getNumber()
         Date start = DatatypeConverter.parseExtendedAttributeDate(baseline.getStart());
         Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());

         if (number == 0)
         {
            mpx.setBaselineCost(cost);
            mpx.setBaselineFinish(finish);
            mpx.setBaselineStart(start);
            mpx.setBaselineWork(work);
         }
         else
         {
            mpx.setBaselineCost(number, cost);
            mpx.setBaselineWork(number, work);
            mpx.setBaselineStart(number, start);
            mpx.setBaselineFinish(number, finish);
         }
      }
   }
1129791
private void readAssignments(Project project)
   {
      Project.Assignments assignments = project.getAssignments();
      if (assignments != null)
      {
         SplitTaskFactory splitFactory = new SplitTaskFactory();
         TimephasedWorkNormaliser normaliser = new MSPDITimephasedWorkNormaliser();
         for (Project.Assignments.Assignment assignment : assignments.getAssignment())
         {
            readAssignment(assignment, splitFactory, normaliser);
         }
      }
   }
1060650
private Assignment initializeAssignment(FactorGraph factorGraph) {
		// Select the initial assignment. 
	  // TODO: Perform a search to find an outcome with nonzero probability.
	  
		Variable[] variables = factorGraph.getVariables().getVariablesArray();
		int[] varNums = factorGraph.getVariables().getVariableNumsArray();
		Object[] values = new Object[variables.length];
		for (int i = 0; i < variables.length; i++) {
			values[i] = variables[i].getArbitraryValue();
		}
		return Assignment.fromSortedArrays(varNums, values);
	}
517450
public void extract(@NotNull final StringValue xmpString, @NotNull Metadata metadata)
    {
        extract(xmpString.getBytes(), metadata, null);
    }
472432
@Override
    public void processXML() throws InjectionException {

        List<? extends JMSConnectionFactory> jmsConnectionFactoryDefinitions = ivNameSpaceConfig.getJNDIEnvironmentRefs(JMSConnectionFactory.class);

        if (jmsConnectionFactoryDefinitions != null) {
            for (JMSConnectionFactory jmsConnectionFactory : jmsConnectionFactoryDefinitions) {
                String jndiName = jmsConnectionFactory.getName();
                InjectionBinding<JMSConnectionFactoryDefinition> injectionBinding = ivAllAnnotationsCollection.get(jndiName);
                JMSConnectionFactoryDefinitionInjectionBinding binding;

                if (injectionBinding != null) {
                    binding = (JMSConnectionFactoryDefinitionInjectionBinding) injectionBinding;
                } else {
                    binding = new JMSConnectionFactoryDefinitionInjectionBinding(jndiName, ivNameSpaceConfig);
                    addInjectionBinding(binding);
                }

                binding.mergeXML(jmsConnectionFactory);
            }
        }

    }
784604
public void assign(Identifier id)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(
        cclass,
        "assign",
        "identifier: " + id);
    
    // Assign ordinal position
    String key = null;
    switch (id.getType()) 
    {
      case Identifier.STRING :
        // Changed from using the Identifier name to using the full name under defect 504438. The full name is only
        // relevant in the XPath Selector Domain and incorporates the full path for the attribute or element referenced.
        // This is necessary so that we are able to distinguish between common names at the same depth in an XML
        // document. For example you might encounter 2 XPath expressions:
        //
        // /company/department[@name='test'] and /company/location[@name='London']
        //
        // We must ensure that the system can distinguish these attributes.
        //
        key = "S:" + id.getFullName();
        break;
      case Identifier.BOOLEAN :
        key = "B:" + id.getFullName();
        break;
      case Identifier.CHILD :
        key = "C:" + id.getFullName();
        break;
      case Identifier.TOPIC:
        key = "T:" + id.getFullName();
        break;
      case Identifier.UNKNOWN :
      case Identifier.OBJECT :
        key = "U:" + id.getFullName();
        break;
      default :
        key = "N:" + id.getFullName();
    }
 
    // Get the map for the specified level. The level is only relevant in the XPath Selector Domain. It represents the
    // level of a location step in an XPath expression
    Integer level = new Integer(id.getStep());
    LevelEntry positions = (LevelEntry) levels.get(level);
    if (positions == null)
    {
      positions = new LevelEntry();
      levels.put(level, positions);
    }
    
    int levelPos = 0;
    if (key != null)
    {
      levelPos = positions.getPosition(key);
    }
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
      tc.debug(this,cclass, "assign", "level: " + level + ", levelPos: " + Integer.valueOf(levelPos) + ", for key: " + key);   
    
    // Now we're ready to set the OrdinalPosition
    OrdinalPosition ordPos = new OrdinalPosition(level.intValue(), levelPos);
    id.setOrdinalPosition(ordPos);
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "assign");
  }
876939
@Override
    public int getPlacementForestIndex(DocumentURI uri) {
        int idx = 0;
        try {
            idx = popAndInsert();
        } catch (InterruptedException e) {
            LOG.error("Statistical assignment gets interrupted");
        }
        return idx;
    }
697179
private void readResourceAssignment(Task task, Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment)
   {
      Resource resource = m_projectFile.getResourceByUniqueID(assignment.getResourceID());
      if (resource != null)
      {
         ResourceAssignment mpxjAssignment = task.addResourceAssignment(resource);
         mpxjAssignment.setUniqueID(assignment.getID());
         mpxjAssignment.setWork(Duration.getInstance(assignment.getManHour().doubleValue() * m_workHoursPerDay, TimeUnit.HOURS));
         mpxjAssignment.setUnits(assignment.getUse());
      }
   }
244827
public List<AlignedExpressionTree> getBestAlignments(AlignmentExample example, int beamSize) {
    CfgParser parser = getCfgParser(example);
    ExpressionTree tree = example.getTree();
    
    Factor rootFactor = getRootFactor(tree, parser.getParentVariable());
    
    List<CfgParseTree> parseTrees = parser.beamSearch(example.getWords(), beamSize);
    List<AlignedExpressionTree> expressionTrees = Lists.newArrayList();
    for (CfgParseTree parseTree : parseTrees) {
      if (rootFactor.getUnnormalizedProbability(parseTree.getRoot()) > 0) {
        expressionTrees.add(decodeCfgParse(parseTree, 0));
      }
    }
    return expressionTrees;
  }
85109
static public ParsedColInfo fromOrderByXml(AbstractParsedStmt parsedStmt,
            VoltXMLElement orderByXml, ExpressionAdjuster adjuster) {

        // make sure everything is kosher
        assert(orderByXml.name.equalsIgnoreCase("orderby"));

        // get desc/asc
        String desc = orderByXml.attributes.get("desc");
        boolean descending = (desc != null) && (desc.equalsIgnoreCase("true"));

        // get the columnref or other expression inside the orderby node
        VoltXMLElement child = orderByXml.children.get(0);
        assert(child != null);

        // create the orderby column
        ParsedColInfo orderCol = new ParsedColInfo();
        orderCol.m_orderBy = true;
        orderCol.m_ascending = !descending;
        AbstractExpression orderExpr = parsedStmt.parseExpressionTree(child);
        assert(orderExpr != null);
        orderCol.m_expression = adjuster.adjust(orderExpr);

        // Cases:
        // child could be columnref, in which case it's either a normal column
        // or an expression.
        // The latter could be a case if this column came from a subquery that
        // was optimized out.
        // Just make a ParsedColInfo object for it and the planner will do the
        // right thing later.
        if (orderExpr instanceof TupleValueExpression) {
            TupleValueExpression tve = (TupleValueExpression) orderExpr;
            orderCol.m_columnName = tve.getColumnName();
            orderCol.m_tableName = tve.getTableName();
            orderCol.m_tableAlias = tve.getTableAlias();
            if (orderCol.m_tableAlias == null) {
                orderCol.m_tableAlias = orderCol.m_tableName;
            }

            orderCol.m_alias = tve.getColumnAlias();
        }
        else {
            String alias = child.attributes.get("alias");
            orderCol.m_alias = alias;
            orderCol.m_tableName = AbstractParsedStmt.TEMP_TABLE_NAME;
            orderCol.m_tableAlias = AbstractParsedStmt.TEMP_TABLE_NAME;
            orderCol.m_columnName = "";
            // Replace its expression to TVE after we build the ExpressionIndexMap

            if ((child.name.equals("operation") == false) &&
                    (child.name.equals("aggregation") == false) &&
                    (child.name.equals("win_aggregation") == false) &&
                    (child.name.equals("function") == false) &&
                    (child.name.equals("rank") == false) &&
                    (child.name.equals("value") == false) &&
                    (child.name.equals("columnref") == false)) {
               throw new RuntimeException(
                       "ORDER BY parsed with strange child node type: " +
                       child.name);
            }
        }

        return orderCol;
    }
1024184
public final void mPLUS_ASSIGN() throws RecognitionException {
		try {
			int _type = PLUS_ASSIGN;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// src/main/resources/org/drools/compiler/lang/DRL5Lexer.g:156:5: ( '+=' )
			// src/main/resources/org/drools/compiler/lang/DRL5Lexer.g:156:7: '+='
			{
			match("+="); if (state.failed) return;

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
376540
public void extract(@NotNull final String xmpString, @NotNull Metadata metadata)
    {
        extract(xmpString, metadata, null);
    }
705956
public void processAssignments(List<Row> rows)
   {
      for (Row row : rows)
      {
         Task task = m_project.getTaskByUniqueID(mapTaskID(row.getInteger("task_id")));
         Resource resource = m_project.getResourceByUniqueID(row.getInteger("rsrc_id"));
         if (task != null && resource != null)
         {
            ResourceAssignment assignment = task.addResourceAssignment(resource);
            processFields(m_assignmentFields, row, assignment);

            populateField(assignment, AssignmentField.START, AssignmentField.BASELINE_START, AssignmentField.ACTUAL_START);
            populateField(assignment, AssignmentField.FINISH, AssignmentField.BASELINE_FINISH, AssignmentField.ACTUAL_FINISH);

            // include actual overtime work in work calculations
            Duration remainingWork = row.getDuration("remain_qty");
            Duration actualOvertimeWork = row.getDuration("act_ot_qty");
            Duration actualRegularWork = row.getDuration("act_reg_qty");
            Duration actualWork = Duration.add(actualOvertimeWork, actualRegularWork, m_project.getProjectProperties());
            Duration totalWork = Duration.add(actualWork, remainingWork, m_project.getProjectProperties());
            assignment.setActualWork(actualWork);
            assignment.setWork(totalWork);

            // include actual overtime cost in cost calculations
            Double remainingCost = row.getDouble("remain_cost");
            Double actualOvertimeCost = row.getDouble("act_ot_cost");
            Double actualRegularCost = row.getDouble("act_reg_cost");
            double actualCost = NumberHelper.getDouble(actualOvertimeCost) + NumberHelper.getDouble(actualRegularCost);
            double totalCost = actualCost + NumberHelper.getDouble(remainingCost);
            assignment.setActualCost(NumberHelper.getDouble(actualCost));
            assignment.setCost(NumberHelper.getDouble(totalCost));

            double units;
            if (resource.getType() == ResourceType.MATERIAL)
            {
               units = (totalWork == null) ? 0 : totalWork.getDuration() * 100;
            }
            else // RT_Labor & RT_Equip
            {
               units = NumberHelper.getDouble(row.getDouble("target_qty_per_hr")) * 100;
            }
            assignment.setUnits(NumberHelper.getDouble(units));

            // Add User Defined Fields
            populateUserDefinedFieldValues("TASKRSRC", FieldTypeClass.ASSIGNMENT, assignment, assignment.getUniqueID());

            m_eventManager.fireAssignmentReadEvent(assignment);
         }
      }

      updateTaskCosts();
   }
916284
private void writeTaskExtendedAttributes(Project.Tasks.Task xml, Task mpx)
   {
      Project.Tasks.Task.ExtendedAttribute attrib;
      List<Project.Tasks.Task.ExtendedAttribute> extendedAttributes = xml.getExtendedAttribute();

      for (TaskField mpxFieldID : getAllTaskExtendedAttributes())
      {
         Object value = mpx.getCachedValue(mpxFieldID);

         if (FieldTypeHelper.valueIsNotDefault(mpxFieldID, value))
         {
            m_extendedAttributesInUse.add(mpxFieldID);

            Integer xmlFieldID = Integer.valueOf(MPPTaskField.getID(mpxFieldID) | MPPTaskField.TASK_FIELD_BASE);

            attrib = m_factory.createProjectTasksTaskExtendedAttribute();
            extendedAttributes.add(attrib);
            attrib.setFieldID(xmlFieldID.toString());
            attrib.setValue(DatatypeConverter.printExtendedAttribute(this, value, mpxFieldID.getDataType()));
            attrib.setDurationFormat(printExtendedAttributeDurationFormat(value));
         }
      }
   }
850329
private Project.Assignments.Assignment writeAssignment(ResourceAssignment mpx)
   {
      Project.Assignments.Assignment xml = m_factory.createProjectAssignmentsAssignment();

      xml.setActualCost(DatatypeConverter.printCurrency(mpx.getActualCost()));
      xml.setActualFinish(mpx.getActualFinish());
      xml.setActualOvertimeCost(DatatypeConverter.printCurrency(mpx.getActualOvertimeCost()));
      xml.setActualOvertimeWork(DatatypeConverter.printDuration(this, mpx.getActualOvertimeWork()));
      xml.setActualStart(mpx.getActualStart());
      xml.setActualWork(DatatypeConverter.printDuration(this, mpx.getActualWork()));
      xml.setACWP(DatatypeConverter.printCurrency(mpx.getACWP()));
      xml.setBCWP(DatatypeConverter.printCurrency(mpx.getBCWP()));
      xml.setBCWS(DatatypeConverter.printCurrency(mpx.getBCWS()));
      xml.setBudgetCost(DatatypeConverter.printCurrency(mpx.getBudgetCost()));
      xml.setBudgetWork(DatatypeConverter.printDuration(this, mpx.getBudgetWork()));
      xml.setCost(DatatypeConverter.printCurrency(mpx.getCost()));

      if (mpx.getCostRateTableIndex() != 0)
      {
         xml.setCostRateTable(BigInteger.valueOf(mpx.getCostRateTableIndex()));
      }

      xml.setCreationDate(mpx.getCreateDate());
      xml.setCV(DatatypeConverter.printCurrency(mpx.getCV()));
      xml.setDelay(DatatypeConverter.printDurationInIntegerTenthsOfMinutes(mpx.getDelay()));
      xml.setFinish(mpx.getFinish());
      xml.setGUID(mpx.getGUID());
      xml.setHasFixedRateUnits(Boolean.valueOf(mpx.getVariableRateUnits() == null));
      xml.setFixedMaterial(Boolean.valueOf(mpx.getResource() != null && mpx.getResource().getType() == ResourceType.MATERIAL));
      xml.setHyperlink(mpx.getHyperlink());
      xml.setHyperlinkAddress(mpx.getHyperlinkAddress());
      xml.setHyperlinkSubAddress(mpx.getHyperlinkSubAddress());
      xml.setLevelingDelay(DatatypeConverter.printDurationInIntegerTenthsOfMinutes(mpx.getLevelingDelay()));
      xml.setLevelingDelayFormat(DatatypeConverter.printDurationTimeUnits(mpx.getLevelingDelay(), false));

      if (!mpx.getNotes().isEmpty())
      {
         xml.setNotes(mpx.getNotes());
      }

      xml.setOvertimeCost(DatatypeConverter.printCurrency(mpx.getOvertimeCost()));
      xml.setOvertimeWork(DatatypeConverter.printDuration(this, mpx.getOvertimeWork()));
      xml.setPercentWorkComplete(NumberHelper.getBigInteger(mpx.getPercentageWorkComplete()));
      xml.setRateScale(mpx.getVariableRateUnits() == null ? null : DatatypeConverter.printTimeUnit(mpx.getVariableRateUnits()));
      xml.setRegularWork(DatatypeConverter.printDuration(this, mpx.getRegularWork()));
      xml.setRemainingCost(DatatypeConverter.printCurrency(mpx.getRemainingCost()));
      xml.setRemainingOvertimeCost(DatatypeConverter.printCurrency(mpx.getRemainingOvertimeCost()));
      xml.setRemainingOvertimeWork(DatatypeConverter.printDuration(this, mpx.getRemainingOvertimeWork()));
      xml.setRemainingWork(DatatypeConverter.printDuration(this, mpx.getRemainingWork()));
      xml.setResourceUID(mpx.getResource() == null ? BigInteger.valueOf(NULL_RESOURCE_ID.intValue()) : BigInteger.valueOf(NumberHelper.getInt(mpx.getResourceUniqueID())));
      xml.setResume(mpx.getResume());
      xml.setStart(mpx.getStart());
      xml.setStop(mpx.getStop());
      xml.setSV(DatatypeConverter.printCurrency(mpx.getSV()));
      xml.setTaskUID(NumberHelper.getBigInteger(mpx.getTask().getUniqueID()));
      xml.setUID(NumberHelper.getBigInteger(mpx.getUniqueID()));
      xml.setUnits(DatatypeConverter.printUnits(mpx.getUnits()));
      xml.setVAC(DatatypeConverter.printCurrency(mpx.getVAC()));
      xml.setWork(DatatypeConverter.printDuration(this, mpx.getWork()));
      xml.setWorkContour(mpx.getWorkContour());

      xml.setCostVariance(DatatypeConverter.printCurrency(mpx.getCostVariance()));
      xml.setWorkVariance(DatatypeConverter.printDurationInDecimalThousandthsOfMinutes(mpx.getWorkVariance()));
      xml.setStartVariance(DatatypeConverter.printDurationInIntegerThousandthsOfMinutes(mpx.getStartVariance()));
      xml.setFinishVariance(DatatypeConverter.printDurationInIntegerThousandthsOfMinutes(mpx.getFinishVariance()));

      writeAssignmentBaselines(xml, mpx);

      writeAssignmentExtendedAttributes(xml, mpx);

      writeAssignmentTimephasedData(mpx, xml);

      m_eventManager.fireAssignmentWrittenEvent(mpx);

      return (xml);
   }
532461
private void populateResourceAssignment(Record record, ResourceAssignment assignment) throws MPXJException
   {
      //
      // Handle malformed MPX files - ensure that we can locate the resource
      // using either the Unique ID attribute or the ID attribute.
      //
      Resource resource = m_projectFile.getResourceByUniqueID(record.getInteger(12));
      if (resource == null)
      {
         resource = m_projectFile.getResourceByID(record.getInteger(0));
      }

      assignment.setUnits(record.getUnits(1));
      assignment.setWork(record.getDuration(2));
      assignment.setBaselineWork(record.getDuration(3));
      assignment.setActualWork(record.getDuration(4));
      assignment.setOvertimeWork(record.getDuration(5));
      assignment.setCost(record.getCurrency(6));
      assignment.setBaselineCost(record.getCurrency(7));
      assignment.setActualCost(record.getCurrency(8));
      assignment.setStart(record.getDateTime(9));
      assignment.setFinish(record.getDateTime(10));
      assignment.setDelay(record.getDuration(11));

      //
      // Calculate the remaining work
      //
      Duration work = assignment.getWork();
      Duration actualWork = assignment.getActualWork();
      if (work != null && actualWork != null)
      {
         if (work.getUnits() != actualWork.getUnits())
         {
            actualWork = actualWork.convertUnits(work.getUnits(), m_projectFile.getProjectProperties());
         }

         assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
      }

      if (resource != null)
      {
         assignment.setResourceUniqueID(resource.getUniqueID());
         resource.addResourceAssignment(assignment);
      }

      m_eventManager.fireAssignmentReadEvent(assignment);
   }
311793
private void readResourceExtendedAttributes(Project.Resources.Resource xml, Resource mpx)
   {
      for (Project.Resources.Resource.ExtendedAttribute attrib : xml.getExtendedAttribute())
      {
         int xmlFieldID = Integer.parseInt(attrib.getFieldID()) & 0x0000FFFF;
         ResourceField mpxFieldID = MPPResourceField.getInstance(xmlFieldID);
         TimeUnit durationFormat = DatatypeConverter.parseDurationTimeUnits(attrib.getDurationFormat(), null);
         DatatypeConverter.parseExtendedAttribute(m_projectFile, mpx, attrib.getValue(), mpxFieldID, durationFormat);
      }
   }