/**
   * Update the Incident Command Structure work product and optionally associate it with incident by
   * supplying the incident identifier (Interest Group identifier).
   *
   * @param UpdateCommandStructureRequestDocument
   * @return UpdateCommandStructureResponseDocument
   * @see <a href="../../services/IncidentCommand/0.1/IncidentCommandStructure.xsd">Appendix:
   *     IncidentCommandStructure.xsd</a>
   * @see <a href="../../services/IncidentCommand/0.1/OrganizationElement.xsd">Appendix:
   *     OrganizationElement.xsd</a>
   * @idd
   */
  @PayloadRoot(
      namespace = NS_IncidentCommandStructureService,
      localPart = "UpdateCommandStructureRequest")
  public UpdateCommandStructureResponseDocument updateCommandStructure(
      UpdateCommandStructureRequestDocument request) {

    log.debug(request.toString());
    OrganizationElementDocument orgDoc = OrganizationElementDocument.Factory.newInstance();
    orgDoc
        .addNewOrganizationElement()
        .set(request.getUpdateCommandStructureRequest().getOrganizationElement());

    UpdateCommandStructureResponseDocument response =
        UpdateCommandStructureResponseDocument.Factory.newInstance();
    response
        .addNewUpdateCommandStructureResponse()
        .addNewWorkProductPublicationResponse()
        .set(
            WorkProductHelper.toWorkProductPublicationResponse(
                icService.updateCommandStructure(
                    request.getUpdateCommandStructureRequest().getWorkProductIdentification(),
                    orgDoc,
                    request.getUpdateCommandStructureRequest().getIncidentID())));
    return response;
  }
  /**
   * Create an Incident Command Structure work product and optionally associate with an incident by
   * supplying the incident identifier (Interest Group identifier). ICS type structures are created
   * if the top level role is "Incident Commander". Otherwise the work product is of type MACS.
   *
   * @param CreateCommandStructureRequestDocument
   * @return CreateCommandStructureResponseDocument
   * @see <a href="../../services/IncidentCommand/0.1/IncidentCommandStructure.xsd">Appendix:
   *     IncidentCommandStructure.xsd</a>
   * @see <a href="../../services/IncidentCommand/0.1/OrganizationElement.xsd">Appendix:
   *     OrganizationElement.xsd</a>
   * @idd
   */
  @PayloadRoot(
      namespace = NS_IncidentCommandStructureService,
      localPart = "CreateCommandStructureRequest")
  public CreateCommandStructureResponseDocument createCommandStructure(
      CreateCommandStructureRequestDocument request) {

    UpdateCommandStructureRequestDocument updateRequest =
        UpdateCommandStructureRequestDocument.Factory.newInstance();
    updateRequest
        .addNewUpdateCommandStructureRequest()
        .addNewOrganizationElement()
        .set(request.getCreateCommandStructureRequest().getOrganizationElement());

    UpdateCommandStructureResponseDocument updateResponse = updateCommandStructure(updateRequest);

    CreateCommandStructureResponseDocument response =
        CreateCommandStructureResponseDocument.Factory.newInstance();
    response
        .addNewCreateCommandStructureResponse()
        .addNewWorkProductPublicationResponse()
        .set(
            updateResponse.getUpdateCommandStructureResponse().getWorkProductPublicationResponse());
    return response;
  }