Search in sources :

Example 31 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class WorkPlansColumnFiller method fillProductNames.

private void fillProductNames(final Entity technology, final Map<Entity, Map<String, String>> valuesMap) {
    EntityTree operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    for (Entity operationComponent : operationComponents) {
        EntityList operationProductInComponents = operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS);
        EntityList operationProductOutComponents = operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS);
        for (Entity operationProductInComponent : operationProductInComponents) {
            initMap(valuesMap, operationProductInComponent);
            valuesMap.get(operationProductInComponent).put(L_PRODUCT_NAME, getProductNameAndNumber(operationProductInComponent));
        }
        for (Entity operationProductOutComponent : operationProductOutComponents) {
            initMap(valuesMap, operationProductOutComponent);
            valuesMap.get(operationProductOutComponent).put(L_PRODUCT_NAME, getProductNameAndNumber(operationProductOutComponent));
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList) EntityTree(com.qcadoo.model.api.EntityTree)

Example 32 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class WorkPlansColumnFiller method fillPlannedQuantities.

private void fillPlannedQuantities(final Entity technology, final OperationProductComponentWithQuantityContainer productQuantities, final Map<Entity, Map<String, String>> valuesMap) {
    EntityTree operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    for (Entity operationComponent : operationComponents) {
        EntityList operationProductInComponents = operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS);
        EntityList operationProductOutComponents = operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS);
        for (Entity operationProductInComponent : operationProductInComponents) {
            initMap(valuesMap, operationProductInComponent);
            valuesMap.get(operationProductInComponent).put(L_PLANNED_QUANTITY, getProductQuantityAndUnit(operationProductInComponent, productQuantities));
        }
        for (Entity operationProductOutComponent : operationProductOutComponents) {
            initMap(valuesMap, operationProductOutComponent);
            valuesMap.get(operationProductOutComponent).put(L_PLANNED_QUANTITY, getProductQuantityAndUnit(operationProductOutComponent, productQuantities));
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList) EntityTree(com.qcadoo.model.api.EntityTree)

Example 33 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class ShiftTest method init.

@Before
public final void init() {
    MockitoAnnotations.initMocks(this);
    given(shiftEntity.copy()).willReturn(shiftEntity);
    EntityList emptyEntityList = mockEntityList(Lists.<Entity>newArrayList());
    given(shiftEntity.getHasManyField(Mockito.anyString())).willReturn(emptyEntityList);
}
Also used : EntityList(com.qcadoo.model.api.EntityList) Before(org.junit.Before)

Example 34 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class ShiftTest method mockEntityList.

private EntityList mockEntityList(final List<Entity> entities) {
    EntityList entityList = mock(EntityList.class);
    given(entityList.iterator()).willReturn(entities.iterator());
    given(entityList.isEmpty()).willReturn(entities.isEmpty());
    return entityList;
}
Also used : EntityList(com.qcadoo.model.api.EntityList)

Example 35 with EntityList

use of com.qcadoo.model.api.EntityList in project mes by qcadoo.

the class CatNumbersInDeliveriesServiceImplTest method mockEntityList.

private static EntityList mockEntityList(final List<Entity> entities) {
    final EntityList entitiesList = mock(EntityList.class);
    given(entitiesList.iterator()).willAnswer(new Answer<Iterator<Entity>>() {

        @Override
        public Iterator<Entity> answer(final InvocationOnMock invocation) throws Throwable {
            return ImmutableList.copyOf(entities).iterator();
        }
    });
    given(entitiesList.isEmpty()).willReturn(entities.isEmpty());
    return entitiesList;
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) EntityList(com.qcadoo.model.api.EntityList) Iterator(java.util.Iterator)

Aggregations

EntityList (com.qcadoo.model.api.EntityList)103 Entity (com.qcadoo.model.api.Entity)52 Test (org.junit.Test)27 DataDefinition (com.qcadoo.model.api.DataDefinition)16 SearchCriteriaBuilder (com.qcadoo.model.api.search.SearchCriteriaBuilder)16 Before (org.junit.Before)11 UserFieldsMF (com.qcadoo.mes.materialFlow.constants.UserFieldsMF)10 UserLocationFields (com.qcadoo.mes.materialFlow.constants.UserLocationFields)10 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)10 SearchRestrictions (com.qcadoo.model.api.search.SearchRestrictions)10 SecurityService (com.qcadoo.security.api.SecurityService)10 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)10 Objects (java.util.Objects)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Service (org.springframework.stereotype.Service)10 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)9 BigDecimal (java.math.BigDecimal)9 StateChangeTest (com.qcadoo.mes.states.StateChangeTest)5