package org.marsik.elshelves.backend.entities.converters;

import org.marsik.elshelves.api.entities.BoxApiModel;
import org.marsik.elshelves.backend.entities.Box;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.UUID;

@Service
public class EmberToBox extends AbstractEmberToEntity<BoxApiModel, Box> {
    @Autowired
    EmberToUser emberToUser;

	@Autowired
	EmberToNamedObject emberToNamedObject;

	public EmberToBox() {
		super(Box.class);
	}

	@Override
	public Box convert(BoxApiModel object, Box box, int nested, Map<UUID, Object> cache) {
		emberToNamedObject.convert(object, box, nested, cache);
		box.setParent(convert(object.getParent(), 1, cache));

		if (object.getLots() == null) {
			box.setLots(null);
		}

		if (object.getBoxes() == null) {
			box.setContains(null);
		}

		return box;
	}
}

@@ -156,16 +156,79 @@
 es.Box;%0A
+import org.marsik.elshelves.backend.entities.IdentifiedEntity;%0A
 import o
@@ -868,19 +868,53 @@
 etLots(n
-ull
+ew IdentifiedEntity.UnprovidedSet%3C%3E()
 );%0A%09%09%7D%0A%0A

Use UnprovidedSet when converting ember to Box.lots