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.DconfigPaPfUoHController;
import it.micegroup.gestioneferie.configurazionepf.dto.DconfigPaPfUoHDto;
import it.micegroup.gestioneferie.configurazionepf.entity.DconfigPaPfUoH;

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

@Component
public class DconfigPaPfUoHModelAssembler
		extends BaseModelAssembler<DconfigPaPfUoH, DconfigPaPfUoHDto, DconfigPaPfUoHController> {

	@Override
	public DconfigPaPfUoHDto toModel(DconfigPaPfUoH dconfigPaPfUoH) {
		DconfigPaPfUoHDto dconfigPaPfUoHDto = map(dconfigPaPfUoH, DconfigPaPfUoHDto.class,
				DconfigPaPfUoHController.class);

		// SELF LINK
		Link selfLink = convert(
				linkTo(methodOn(DconfigPaPfUoHController.class).getByObjectKey(dconfigPaPfUoH.getObjectKey()))
						.withSelfRel());
		dconfigPaPfUoHDto.add(selfLink);

		// PARENT LINKS
		if (dconfigPaPfUoH.getTheDconfigPaPianiFerie() != null) {
			Link dconfigPaPianiFerieLink = convert(linkTo(methodOn(DconfigPaPianiFerieController.class)
					.getByObjectKey(dconfigPaPfUoH.getTheDconfigPaPianiFerieObjectKey()))
							.withRel("theDconfigPaPianiFerie"));
			dconfigPaPfUoHDto.add(dconfigPaPianiFerieLink);
		}

		// CHILDREN LINKS

		// PARENTS LINKS FOR IMPORTED MS

		// CHILDREN LINKS FOR IMPORTED MS

		return dconfigPaPfUoHDto;

	}

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

		return collectionEntities;
	}

}

