package it.micegroup.gestioneferie.configurazionepf.assembler;

import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.Link;
import org.springframework.stereotype.Component;

import it.micegroup.gestioneferie.libs.assembler.BaseModelAssembler;
import it.micegroup.gestioneferie.configurazionepf.controller.DregolePianiFerieHController;
import it.micegroup.gestioneferie.configurazionepf.dto.DregolePianiFerieHDto;
import it.micegroup.gestioneferie.configurazionepf.entity.DregolePianiFerieH;

import it.micegroup.gestioneferie.configurazionepf.controller.DregolePianiFeriePkController;

@Component
public class DregolePianiFerieHModelAssembler
		extends BaseModelAssembler<DregolePianiFerieH, DregolePianiFerieHDto, DregolePianiFerieHController> {

	@Override
	public DregolePianiFerieHDto toModel(DregolePianiFerieH dregolePianiFerieH) {
		DregolePianiFerieHDto dregolePianiFerieHDto = map(dregolePianiFerieH, DregolePianiFerieHDto.class,
				DregolePianiFerieHController.class);

		// SELF LINK
		Link selfLink = convert(
				linkTo(methodOn(DregolePianiFerieHController.class).getByObjectKey(dregolePianiFerieH.getObjectKey()))
						.withSelfRel());
		dregolePianiFerieHDto.add(selfLink);

		// PARENT LINKS
		if (dregolePianiFerieH.getTheDregolePianiFeriePk() != null) {
			Link dregolePianiFeriePkLink = convert(linkTo(methodOn(DregolePianiFeriePkController.class)
					.getByObjectKey(dregolePianiFerieH.getTheDregolePianiFeriePkObjectKey()))
							.withRel("theDregolePianiFeriePk"));
			dregolePianiFerieHDto.add(dregolePianiFeriePkLink);
		}

		// CHILDREN LINKS

		// PARENTS LINKS FOR IMPORTED MS

		// CHILDREN LINKS FOR IMPORTED MS

		return dregolePianiFerieHDto;

	}

	@Override
	public CollectionModel<DregolePianiFerieHDto> toCollectionModel(Iterable<? extends DregolePianiFerieH> entities) {
		CollectionModel<DregolePianiFerieHDto> collectionEntities = super.toCollectionModel(entities);
		// collectionEntities.add(linkTo(methodOn(OrdineController.class).findPaginated(null,
		// null)).withSelfRel());

		return collectionEntities;
	}

}

