InvitroInventoryApiService.java
/*
* Copyright 2022 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gringlobal.api.v2.facade;
import org.gringlobal.api.model.InventoryDTO;
import org.gringlobal.api.model.InventoryInfo;
import org.gringlobal.api.model.InventoryMaintenancePolicyInfo;
import org.gringlobal.api.model.MaterielInfo;
import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.custom.validation.javax.OneLine;
import org.gringlobal.custom.validation.javax.SimpleString;
import org.gringlobal.model.community.CommunityCodeValues;
import org.gringlobal.service.InventoryService;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* Services for in vitro collections.
*/
public interface InvitroInventoryApiService {
class IVMultiplicationRequestDTO {
@NotNull
public InventoryInfo sourceInventory;
@Min(0)
public int quantityToDeduct;
@NotNull
public List<IVMultiplicationItemDTO> multiplicationItems;
}
class IVMultiplicationItemDTO {
public String inventoryNumberPart1;
@OneLine
@SimpleString
public String inventoryNumberPart3;
@CodeValueField(CommunityCodeValues.GERMPLASM_FORM)
public String formTypeCode;
@CodeValueField(CommunityCodeValues.CONTAINER_TYPE)
public String containerTypeCode;
@Min(0)
public Double quantityOnHand;
@CodeValueField(CommunityCodeValues.UNIT_OF_QUANTITY)
public String quantityOnHandUnitCode;
@NotNull
public InventoryMaintenancePolicyInfo inventoryMaintenancePolicy;
public MaterielInfo medium;
public Date introductionDate;
@CodeValueField(CommunityCodeValues.DATE_FORMAT)
public String introductionDateCode;
public boolean autoDeducted = true;
@CodeValueField("INVENTORY_AVAILABILITY_REASON")
public String availabilityReasonCode;
@CodeValueField(value = CommunityCodeValues.PATHOGEN_STATUS)
public String pathogenStatusCode;
public String note;
}
/**
* Initiate the introduction of new material for in vitro conservation
*
* @return List of registered inventories
*/
List<InventoryDTO> invitroStart(@Valid IVMultiplicationRequestDTO request);
/**
* Multiply existing in vitro Inventory,
* similar to {@link InventoryService#splitInventory(InventoryService.SplitInventoryRequest)}.
*
* @return
*/
List<InventoryDTO> invitroMultiply(@Valid IVMultiplicationRequestDTO request);
}