code: private Project.Tasks.Task.PredecessorLink writePredecessor(Integer taskID, RelationType type, Duration lag)
     {
        Project.Tasks.Task.PredecessorLink link = m_factory.createProjectTasksTaskPredecessorLink();
  
        link.setPredecessorUID(NumberHelper.getBigInteger(taskID));
        link.setType(BigInteger.valueOf(type.getValue()));
        link.setCrossProject(Boolean.FALSE); // SF-300: required to keep P6 happy when importing MSPDI files
  
        if (lag != null && lag.getDuration() != 0)
        {
           double linkLag = lag.getDuration();
           if (lag.getUnits() != TimeUnit.PERCENT && lag.getUnits() != TimeUnit.ELAPSED_PERCENT)
           {
              linkLag = 10.0 * Duration.convertUnits(linkLag, lag.getUnits(), TimeUnit.MINUTES, m_projectFile.getProjectProperties()).getDuration();
           }
           link.setLinkLag(BigInteger.valueOf((long) linkLag));
           link.setLagFormat(DatatypeConverter.printDurationTimeUnits(lag.getUnits(), false));
        }
        else
        {
           // SF-329: default required to keep Powerproject happy when importing MSPDI files
           link.setLinkLag(BIGINTEGER_ZERO);
           link.setLagFormat(DatatypeConverter.printDurationTimeUnits(m_projectFile.getProjectProperties().getDefaultDurationUnits(), false));
        }
  
        return (link);
     }
docs: This method writes a single predecessor link to the MSPDI file.
  
  @param taskID The task UID
  @param type The predecessor type
  @param lag The lag duration
  @return A new link to be added to the MSPDI file