.getPaths().addAll(toPathTO(model.getPaths()));
    result.getLocationTypes().addAll(toLocationTypeTO(model.getLocationTypes()));
    result.getLocations().addAll(toLocationTO(model.getLocations()));
    result.getBlocks().addAll(toBlockTO(model.getBlocks()));
    result.setVisualLayout(toVisualLayoutTO(model.getVisualLayout()));
    result.getProperties().addAll(convertProperties(model.getProperties()));

    return result;
  }

  //Methods for mapping from PlantModelElementTO to CreationTO start here.
  private List<PointCreationTO> toPointCreationTO(List<PointTO> points) {
    List<PointCreationTO> result = new ArrayList<>();

    for (PointTO point : points) {
      result.add(
          new PointCreationTO(point.getName())
             .withPosition(new Triple(point.getxPosition(),
                                       point.getyPosition(),
                                       point.getzPosition()))
             .withVehicleOrientationAngle(point.getVehicleOrientationAngle().doubleValue())
             .withType(Point.Type.valueOf(point.getType()))
             .withProperties(convertProperties(point.getProperties()))
             .withLayout(new PointCreationTO.Layout(new Couple(point.getPointLayout().getxPosition(),
                                                                point.getPointLayout().getyPosition()),
                                                     new Couple(point.getPointLayout().getxLabelOffset(),
                                                                point.getPointLayout().getyLabelOffset()),
                                                     point.getPointLayout().getLayerId()))
      );
    }

    return result;
  }

  private List<VehicleCreationTO> toVehicleCreationTO(List<VehicleTO> vehicles) {
    List<VehicleCreationTO> result = new ArrayList<>();

    for (VehicleTO vehicle : vehicles) {
      result.add(
          new VehicleCreationTO(vehicle.getName())
             .withLength(vehicle.getLength().intValue())
             .withEnergyLevelCritical(vehicle.getEnergyLevelCritical().intValue())
             .withEnergyLevelGood(vehicle.getEnergyLevelGood().intValue())
             .withEnergyLevelFullyRecharged(vehicle.getEnergyLevelFullyRecharged().intValue())
             .withEnergyLevelSufficientlyRecharged(vehicle.getEnergyLevelSufficientlyRecharged().intValue())
             .withMaxReverseVelocity(vehicle.getMaxReverseVelocity())
             .withMaxVelocity(vehicle.getMaxVelocity())
             .withProperties(convertProperties(vehicle.getProperties()))
             .withLayout(new VehicleCreationTO.Layout(
                  Colors.decodeFromHexRGB(vehicle.getVehicleLayout().getColor())
              ))
      );
    }

    return result;
  }

  private List<PathCreationTO> toPathCreationTO(List<PathTO> paths) {
    List<PathCreationTO> result = new ArrayList<>();

    for (PathTO path : paths) {
      result.add(
          new PathCreationTO(path.getName(),
                             path.getSourcePoint(),
                             path.getDestinationPoint())
             .withLength(path.getLength())
             .withLocked(path.isLocked())
             .withMaxVelocity(path.getMaxVelocity().intValue())
             .withMaxReverseVelocity(path.getMaxReverseVelocity().intValue())
             .withPeripheralOperations(
                  toPeripheralOperationCreationTOs(path.getPeripheralOperations())
              )
             .withProperties(convertProperties(path.getProperties()))
             .withLayout(new PathCreationTO.Layout(
                  Path.Layout.ConnectionType.valueOf(path.getPathLayout().getConnectionType()),
                  path.getPathLayout().getControlPoints().stream()
                     .map(controlPoint -> new Couple(controlPoint.getX(), controlPoint.getY()))
                     .collect(Collectors.toList()),
                  path.getPathLayout().getLayerId()
              ))
      );
    }

    return result;
  }

  private List<PeripheralOperationCreationTO> toPeripheralOperationCreationTOs(
      List<PeripheralOperationTO> tos) {
    return tos.stream()
       .map(
            to -> new PeripheralOperationCreationTO(to.getName(), to.getLocationName())
               .withExecutionTrigger(
                    PeripheralOperation.ExecutionTrigger.valueOf(to.getExecutionTrigger())
                )
               .withCompletionRequired(to.isCompletionRequired())
        )
       .collect(Collectors.toList());
  }

  private List<LocationTypeCreationTO> toLocationTypeCreationTO(
      List<LocationTypeTO> locationTypes) {
    List<LocationTypeCreationTO> result = new ArrayList<>();

    for (LocationTypeTO locationType : locationTypes) {
      result.add(
          new LocationTypeCreationTO(locationType.getName())
             .withAllowedOperations(getOperationNames(locationType.getAllowedOperations()))
             .withAllowedPeripheralOperations(getPeripheralOperationNames(
                  locationType.getAllowedPeripheralOperations())
              )
             .withProperties(convertProperties(locationType.getProperties()))
             .withLayout(new LocationTypeCreationTO.Layout(
                  LocationRepresentation.valueOf(locationType.getLocationTypeLayout().getLocationRepresentation())
              ))
      );
    }

    return result;
  }

  private List<LocationCreationTO> toLocationCreationTO(List<LocationTO> locations) {
    List<LocationCreationTO> result = new ArrayList<>();

    for (LocationTO location : locations) {
      result.add(
          new LocationCreationTO(location.getName(),
                                 location.getType(),
                                 new Triple(location.getxPosition(),
                                            location.getyPosition(),
                                            location.getzPosition()))
             .withLinks(getLinks(location))
             .withLocked(location.isLocked())
             .withProperties(convertProperties(location.getProperties()))
             .withLayout(new LocationCreationTO.Layout(new Couple(location.getLocationLayout().getxPosition(),
                                                                   location.getLocationLayout().getyPosition()),
                                                        new Couple(location.getLocationLayout().getxLabelOffset(),
                                                                   location.getLocationLayout().getyLabelOffset()),
                                                        LocationRepresentation.valueOf(location.getLocationLayout().getLocationRepresentation()),
                                                        location.getLocationLayout().getLayerId()))
      );
    }

    return result;
  }

  private List<BlockCreationTO> toBlockCreationTO(List<BlockTO> blocks) {
    List<BlockCreationTO> result = new ArrayList<>();

    for (BlockTO block : blocks) {
      result.add(
          new BlockCreationTO(block.getName())
             .withType(Block.Type.valueOf(block.getType()))
             .withMemberNames(block.getMembers().stream()
                 .map(member -> member.getName())
                 .collect(Collectors.toSet()))
             .withProperties(convertProperties(block.getProperties()))
             .withLayout(new BlockCreationTO.Layout(
                  Colors.decodeFromHexRGB(block.getBlockLayout().getColor())
              ))
      );
    }

    return result;
  }

  private VisualLayoutCreationTO toVisualLayoutCreationTO(VisualLayoutTO visualLayout) {
    return new VisualLayoutCreationTO(visualLayout.getName())
       .withScaleX(visualLayout.getScaleX())
       .withScaleY(visualLayout.getScaleY())
       .withLayers(convertLayers(visualLayout.getLayers()))
       .withLayerGroups(convertLayerGroups(visualLayout.getLayerGroups()))
       .withProperties(convertProperties(visualLayout.getProperties()));
  }

  private List<Layer> convertLayers(List<VisualLayoutTO.Layer> layers) {
    List<Layer> result = new ArrayList<>();

    for (VisualLayoutTO.Layer layer : layers) {
      result.add(new Layer(layer.getId(),
                           layer.getOrdinal(),
                           layer.isVisible(),
                           layer.getName(),
                           layer.getGroupId()));
    }

    return result;
  }

  private List<LayerGroup> convertLayerGroups(List<VisualLayoutTO.LayerGroup> layerGroups) {
    List<LayerGroup> result = new ArrayList<>();

    for (VisualLayoutTO.LayerGroup layerGroup : layerGroups) {
      result.add(new LayerGroup(layerGroup.getId(),
                                layerGroup.getName(),
                                layerGroup.isVisible()));
    }

    return result;
  }

  