Projects >> mes >>99443fec9f4538538d0a6f814fc4e3cf20a8a93e

Chunk
Conflicting content
    private List getGenealogies(final Entity entity) {
        List genealogies = new ArrayList();
<<<<<<< HEAD:mes-plugins/mes-plugins-genealogies/src/main/java/com/qcadoo/mes/genealogies/print/GenealogyForComponentView.java
        List batchList = dataDefinitionService.get("genealogiesForComponents", "productInBatch").find()
                .isEq("batch", entity.getField("batch")).list().getEntities();
=======
        List batchList = dataDefinitionService
                .get(GenealogiesForComponentsConstants.PLUGIN_IDENTIFIER,
                        GenealogiesForComponentsConstants.MODEL_PRODUCT_IN_BATCH).find()
                .addRestriction(Restrictions.eq("batch", entity.getField("batch"))).list().getEntities();
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636:mes-plugins/mes-plugins-genealogies-for-components/src/main/java/com/qcadoo/mes/genealogiesForComponents/GenealogyForComponentView.java
        for (Entity batch : batchList) {
            Entity genealogy = ((Entity) ((Entity) batch.getField("productInComponent")).getField("genealogy"));
            if (!genealogies.contains(genealogy)) {
Solution content
    private List getGenealogies(final Entity entity) {
        List genealogies = new ArrayList();
        
        List batchList = dataDefinitionService.get(GenealogiesForComponentsConstants.PLUGIN_IDENTIFIER,
                GenealogiesForComponentsConstants.MODEL_PRODUCT_IN_BATCH).find()
                .isEq("batch", entity.getField("batch")).list().getEntities();

        for (Entity batch : batchList) {
            Entity genealogy = ((Entity) ((Entity) batch.getField("productInComponent")).getField("genealogy"));
            if (!genealogies.contains(genealogy)) {
File
GenealogyForComponentView.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    }

    private boolean checkIfExistGenealogyWithBatch(final Entity order, final String batch) {
<<<<<<< HEAD
        SearchResult searchResult = dataDefinitionService.get("genealogies", "genealogy").find().isEq("batch", batch)
                .isEq("order.id", order.getId()).setMaxResults(1).list();
=======
        SearchResult searchResult = dataDefinitionService
                .get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find()
                .addRestriction(Restrictions.eq("batch", batch)).addRestriction(Restrictions.eq("order.id", order.getId()))
                .setMaxResults(1).list();
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
        if (searchResult.getEntities().size() > 0) {
            return true;
        }
Solution content
    }

    private boolean checkIfExistGenealogyWithBatch(final Entity order, final String batch) {
        SearchResult searchResult = dataDefinitionService
                .get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find().isEq("batch", batch)
                .isEq("order.id", order.getId()).setMaxResults(1).list();

        if (searchResult.getEntities().size() > 0) {
            return true;
        }
File
AutoGenealogyService.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
    }

<<<<<<< HEAD
    public void disableBatchRequiredForTechnology(final ViewDefinitionState state) {
        ComponentState form = state.getComponentByReference("form");
        if (form.getFieldValue() != null) {
            FieldComponent batchRequired = (FieldComponent) state.getComponentByReference("batchRequired");
            if (checkProductInComponentsBatchRequired((Long) form.getFieldValue())) {
                batchRequired.setEnabled(false);
                batchRequired.setFieldValue("1");
                batchRequired.requestComponentUpdateState();
            } else {
                batchRequired.setEnabled(true);
            }
        }

    }

    private boolean checkProductInComponentsBatchRequired(final Long entityId) {
        SearchResult searchResult = dataDefinitionService.get("technologies", "operationProductInComponent").find()
                .isEq("operationComponent.technology.id", entityId).isEq("batchRequired", true).setMaxResults(1).list();

        return (searchResult.getTotalNumberOfEntities() > 0);

    }

=======
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
    private boolean batchRequired(final Long selectedProductId) {
        Entity product = getProductById(selectedProductId);
        if (product != null) {
Solution content
    }

    private boolean batchRequired(final Long selectedProductId) {
        Entity product = getProductById(selectedProductId);
        if (product != null) {
File
GenealogyTechnologyService.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Chunk
Conflicting content
    private List getOrders(final Entity entity) {
        List orders = new ArrayList();
<<<<<<< HEAD
        List genealogyList = dataDefinitionService.get("genealogies", "genealogy").find()
                .isEq("batch", entity.getField("batch")).list().getEntities();
=======
        List genealogyList = dataDefinitionService
                .get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find()
                .addRestriction(Restrictions.eq("batch", entity.getField("batch"))).list().getEntities();
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
        for (Entity genealogy : genealogyList) {
            Entity order = (Entity) genealogy.getField("order");
            if (!orders.contains(order)) {
Solution content
    private List getOrders(final Entity entity) {
        List orders = new ArrayList();

        List genealogyList = dataDefinitionService
                .get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find()
                .isEq("batch", entity.getField("batch")).list().getEntities();

        for (Entity genealogy : genealogyList) {
            Entity order = (Entity) genealogy.getField("order");
            if (!orders.contains(order)) {
File
GenealogyForProductView.java
Developer's decision
Combination
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
            @Override
        batches.setEntities(setDistinctBatch(batches.getEntities()));
    }

<<<<<<< HEAD
    public void addRestrictionToComponentGrid(final ViewDefinitionState viewDefinitionState) {
        final FieldComponent product = (FieldComponent) viewDefinitionState.getComponentByReference("product");
        final GridComponent batches = (GridComponent) viewDefinitionState.getComponentByReference("batches");

        batches.setCustomRestriction(new CustomRestriction() {
            public void addRestriction(final SearchCriteriaBuilder searchCriteriaBuilder) {
                searchCriteriaBuilder.isEq("productInComponent.productInComponent.product.id", product.getFieldValue());
            }

        });

        batches.setEntities(setDistinctBatch(batches.getEntities()));
    }

    private List setDistinctBatch(final List entities) {
=======
    public List setDistinctBatch(final List entities) {
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
        List distinctEntities = new LinkedList();
        Set usedBatches = new HashSet();
        for (Entity genealogyEntity : entities) {
Solution content
        batches.setEntities(setDistinctBatch(batches.getEntities()));
    }

    public List setDistinctBatch(final List entities) {
        List distinctEntities = new LinkedList();
        Set usedBatches = new HashSet();
        for (Entity genealogyEntity : entities) {
File
ReportService.java
Developer's decision
Version 2
Kind of conflict
Method declaration
Method signature
Chunk
Conflicting content
        List list = new ArrayList();
        list.add(mock(Entity.class));
        given(
<<<<<<< HEAD
                dataDefinitionService.get("genealogies", "genealogy").find().isEq("batch", "test")
                        .isEq("order.id", order.getId()).setMaxResults(1).list().getEntities()).willReturn(list);
=======
                dataDefinitionService.get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find()
                        .addRestriction(Restrictions.eq("batch", "test"))
                        .addRestriction(Restrictions.eq("order.id", order.getId())).setMaxResults(1).list().getEntities())
                .willReturn(list);
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636

        given(translationService.translate("genealogies.message.autoGenealogy.genealogyExist", Locale.ENGLISH)).willReturn(
                "genealogies.message.autoGenealogy.genealogyExist.pl");
Solution content
        List list = new ArrayList();
        list.add(mock(Entity.class));
        given(
                dataDefinitionService.get(GenealogiesConstants.PLUGIN_IDENTIFIER, GenealogiesConstants.MODEL_GENEALOGY).find()
                        .isEq("batch", "test").isEq("order.id", order.getId()).setMaxResults(1).list().getEntities()).willReturn(
                list);

        given(translationService.translate("genealogies.message.autoGenealogy.genealogyExist", Locale.ENGLISH)).willReturn(
                "genealogies.message.autoGenealogy.genealogyExist.pl");
File
AutoGenealogyServiceTest.java
Developer's decision
Manual
Kind of conflict
Method invocation
Variable
Chunk
Conflicting content
import com.qcadoo.mes.orders.OrdersConstants;
import com.qcadoo.model.api.DataDefinitionService;
import com.qcadoo.model.api.Entity;
<<<<<<< HEAD
import com.qcadoo.model.api.EntityList;
import com.qcadoo.model.api.EntityTree;
import com.qcadoo.model.internal.DefaultEntity;
import com.qcadoo.model.internal.EntityListImpl;
import com.qcadoo.model.internal.EntityTreeImpl;
=======
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
import com.qcadoo.view.api.ComponentState;
import com.qcadoo.view.api.ViewDefinitionState;
import com.qcadoo.view.api.components.FieldComponent;
Solution content
import com.qcadoo.mes.orders.OrdersConstants;
import com.qcadoo.model.api.DataDefinitionService;
import com.qcadoo.model.api.Entity;
import com.qcadoo.view.api.ComponentState;
import com.qcadoo.view.api.ViewDefinitionState;
import com.qcadoo.view.api.components.FieldComponent;
File
GenealogyServiceTest.java
Developer's decision
Version 2
Kind of conflict
Import
Chunk
Conflicting content
        verifyNoMoreInteractions(state);
    }

<<<<<<< HEAD
    @Test
    public void shouldNoFillProductInComponentsIfFormIsNotValid() throws Exception {
        // given
        FormComponent form = mock(FormComponent.class, Mockito.RETURNS_DEEP_STUBS);
        given(form.isValid()).willReturn(false);

        ViewDefinitionState state = mock(ViewDefinitionState.class);
        given(state.getComponentByReference("form")).willReturn(form);

        // when
        genealogyService.fillProductInComponents(state);

        // then
        verify(state, atLeastOnce()).getComponentByReference(anyString());
        verifyNoMoreInteractions(state);
    }

    @Test
    public void shouldHideProductInComponentsIfThereIsNoTechnology() throws Exception {
        // given
        ComponentState products = mock(ComponentState.class);

        FormComponent form = mock(FormComponent.class, Mockito.RETURNS_DEEP_STUBS);
        given(form.isValid()).willReturn(true);
        given(form.getEntity().getField("order").toString()).willReturn("13");

        Entity order = mock(Entity.class);
        given(order.getBelongsToField("technology")).willReturn(null);

        given(dataDefinitionService.get("orders", "order").get(13L)).willReturn(order);

        ViewDefinitionState state = mock(ViewDefinitionState.class);
        given(state.getComponentByReference("form")).willReturn(form);
        given(state.getComponentByReference("productGridLayout")).willReturn(products);

        // when
        genealogyService.fillProductInComponents(state);

        // then
        verify(products).setVisible(false);

        verify(state, atLeastOnce()).getComponentByReference(anyString());
        verifyNoMoreInteractions(state);
    }

    @Test
    public void shouldHideProductInComponentsIfThereIsNoProductsForGenealogy() throws Exception {
        // given
        ComponentState products = mock(ComponentState.class);

        FormComponent form = mock(FormComponent.class, Mockito.RETURNS_DEEP_STUBS);
        given(form.isValid()).willReturn(true);
        given(form.getEntity().getField("order").toString()).willReturn("13");

        DataDefinition dataDefinition = mock(DataDefinition.class);

        EntityTree operationComponents = new EntityTreeImpl(dataDefinition, "joinField", null);

        Entity technology = mock(Entity.class);
        given(technology.getTreeField("operationComponents")).willReturn(operationComponents);

        Entity order = mock(Entity.class);
        given(order.getBelongsToField("technology")).willReturn(technology);

        given(dataDefinitionService.get("orders", "order").get(13L)).willReturn(order);

        ViewDefinitionState state = mock(ViewDefinitionState.class);
        given(state.getComponentByReference("form")).willReturn(form);
        given(state.getComponentByReference("productGridLayout")).willReturn(products);

        // when
        genealogyService.fillProductInComponents(state);

        // then
        verify(products).setVisible(false);
        verify(state, atLeastOnce()).getComponentByReference(anyString());
        verifyNoMoreInteractions(state);
    }

    @Test
    public void shouldShowProductInComponents() throws Exception {
        // given
        ComponentState products = mock(ComponentState.class);

        FieldComponent productsList = mock(FieldComponent.class);

        List expectedGenealogyProductInComponents = prepareExpectedGenealogyProductInComponents();
        EntityList existingGenealogyProductInComponents = prepareExistingGenealogyProductInComponents();
        EntityTree operationProductInComponents = prepareOperationProductInComponents();

        FormComponent form = mock(FormComponent.class, Mockito.RETURNS_DEEP_STUBS);
        given(form.isValid()).willReturn(true);
        given(form.getEntityId()).willReturn(11L);
        given(form.getEntity().getField("order").toString()).willReturn("13");

        Entity genealogyProductInComponent = new DefaultEntity(null);
        given(dataDefinitionService.get("genealogiesForComponents", "genealogyProductInComponent").create()).willReturn(
                genealogyProductInComponent);

        Entity technology = mock(Entity.class);
        given(technology.getTreeField("operationComponents")).willReturn(operationProductInComponents);

        Entity order = mock(Entity.class);
        given(dataDefinitionService.get("orders", "order").get(13L)).willReturn(order);
        given(order.getBelongsToField("technology")).willReturn(technology);

        Entity genealogy = mock(Entity.class);
        given(dataDefinitionService.get("genealogies", "genealogy").get(11L)).willReturn(genealogy);
        given(genealogy.getHasManyField("productInComponents")).willReturn(existingGenealogyProductInComponents);

        ViewDefinitionState state = mock(ViewDefinitionState.class);
        given(state.getComponentByReference("form")).willReturn(form);
        given(state.getComponentByReference("productGridLayout")).willReturn(products);
        given(state.getComponentByReference("productInComponentsList")).willReturn(productsList);

        // when
        genealogyService.fillProductInComponents(state);

        // then
        verify(products, never()).setVisible(false);
        verify(productsList).setFieldValue(expectedGenealogyProductInComponents);
        verify(state, atLeastOnce()).getComponentByReference(anyString());
        verifyNoMoreInteractions(state);
    }

    @SuppressWarnings("unchecked")
    private EntityTree prepareOperationProductInComponents() {
        List entities = new ArrayList();
        List subEntities = new ArrayList();
        List productsEntities1 = new ArrayList();
        List productsEntities3 = new ArrayList();

    }
        productsEntities1.add(craeteOperationProductInComponent(101L, true));
        productsEntities3.add(craeteOperationProductInComponent(103L, true));
        productsEntities3.add(craeteOperationProductInComponent(104L, false));

        DataDefinition treeDataDefinition = mock(DataDefinition.class, RETURNS_DEEP_STUBS);
        given(treeDataDefinition.find().belongsTo(anyString(), any()).orderAscBy(eq("priority")).list().getEntities())
                .willReturn(entities, subEntities);

        DataDefinition listDataDefinition = mock(DataDefinition.class, RETURNS_DEEP_STUBS);
        given(listDataDefinition.find().belongsTo(anyString(), any()).list().getEntities()).willReturn(productsEntities1,
                productsEntities3);

        EntityTree subOperationComponents = new EntityTreeImpl(treeDataDefinition, "joinField", 13L);

        EntityList operationProductInComponents1 = new EntityListImpl(listDataDefinition, "joinField", 1L);
        EntityList operationProductInComponents3 = new EntityListImpl(listDataDefinition, "joinField", 3L);

        Entity operationComponent1 = mock(Entity.class);
        given(operationComponent1.getId()).willReturn(1L);
        given(operationComponent1.getField("entityType")).willReturn("operation");
        given(operationComponent1.getHasManyField("operationProductInComponents")).willReturn(operationProductInComponents1);
        given(operationComponent1.getBelongsToField("parent")).willReturn(null);

        Entity referenceTechnology = mock(Entity.class);
        given(referenceTechnology.getTreeField("operationComponents")).willReturn(subOperationComponents);

        Entity operationComponent2 = mock(Entity.class);
        given(operationComponent2.getId()).willReturn(2L);
        given(operationComponent2.getField("entityType")).willReturn("referenceTechnology");
        given(operationComponent2.getBelongsToField("referenceTechnology")).willReturn(referenceTechnology);
        given(operationComponent2.getBelongsToField("parent")).willReturn(operationComponent1);

        Entity operationComponent3 = mock(Entity.class);
        given(operationComponent3.getId()).willReturn(3L);
        given(operationComponent3.getField("entityType")).willReturn("operation");
        given(operationComponent3.getHasManyField("operationProductInComponents")).willReturn(operationProductInComponents3);
        given(operationComponent3.getBelongsToField("parent")).willReturn(null);

        entities.add(operationComponent1);
        entities.add(operationComponent2);
        subEntities.add(operationComponent3);

        EntityTree operationComponents = new EntityTreeImpl(treeDataDefinition, "joinField", 13L);
        return operationComponents;
    }

    private EntityList prepareExistingGenealogyProductInComponents() {
        List existingEntities = new ArrayList();
        existingEntities.add(craeteGenealogyProductInComponent(101L, craeteOperationProductInComponent(101L, true)));
        existingEntities.add(craeteGenealogyProductInComponent(102L, craeteOperationProductInComponent(102L, true)));

        DataDefinition existingListDataDefinition = mock(DataDefinition.class, RETURNS_DEEP_STUBS);
        given(existingListDataDefinition.find().belongsTo(anyString(), any()).list().getEntities()).willReturn(existingEntities);

        EntityList existingOperationComponents = new EntityListImpl(existingListDataDefinition, "joinField", 11L);
        return existingOperationComponents;
    }

    private List prepareExpectedGenealogyProductInComponents() {
        List expectedEntities = new ArrayList();
        expectedEntities.add(craeteGenealogyProductInComponent(101L, craeteOperationProductInComponent(101L, true)));
        expectedEntities.add(craeteGenealogyProductInComponent(null, craeteOperationProductInComponent(103L, true)));
        return expectedEntities;
    }

    private Entity craeteGenealogyProductInComponent(final Long id, final Entity operationProductInComponent) {
        Entity genealogyProductInComponent = new DefaultEntity(null, id);
        genealogyProductInComponent.setField("productInComponent", operationProductInComponent);
        return genealogyProductInComponent;
    }
    private Entity craeteOperationProductInComponent(final Long id, final boolean batchRequired) {
        Entity operationProductInComponent = new DefaultEntity(null, id);
        operationProductInComponent.setField("batchRequired", batchRequired);
        return operationProductInComponent;
=======
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
}
Solution content
        verifyNoMoreInteractions(state);
    }

}
File
GenealogyServiceTest.java
Developer's decision
Version 2
Kind of conflict
Annotation
Method declaration
Chunk
Conflicting content
    public void activateOrder(final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) {
        if (state.getFieldValue() != null) {

<<<<<<< HEAD
            // TODO FIXME mady cannot close order in genealogy plugin is not enabled
            DataDefinition orderDataDefinition = dataDefinitionService.get("orders", "order");
=======
            // TODO mady
            DataDefinition orderDataDefinition = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER,
                    OrdersConstants.MODEL_ORDER);
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636
            Entity order = orderDataDefinition.get((Long) state.getFieldValue());

            if (state instanceof FormComponent) {
Solution content
    public void activateOrder(final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) {
        if (state.getFieldValue() != null) {

            // TODO FIXME mady cannot close order if genealogy plugin is not enabled
            DataDefinition orderDataDefinition = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER,
                    OrdersConstants.MODEL_ORDER);

            Entity order = orderDataDefinition.get((Long) state.getFieldValue());

            if (state instanceof FormComponent) {
File
OrderService.java
Developer's decision
Manual
Kind of conflict
Comment
Method invocation
Variable
Chunk
Conflicting content
                TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).getField("qualityControlRequired") == null) {
            return false;
        }
<<<<<<< HEAD
        SearchResult searchResult = dataDefinitionService.get("technologies", "technologyOperationComponent").find()
                .isEq("technology.id", entityId).isEq("qualityControlRequired", true).setMaxResults(1).list();
=======
        SearchResult searchResult = dataDefinitionService
                .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).find()
                .addRestriction(Restrictions.eq("technology.id", entityId))
                .addRestriction(Restrictions.eq("qualityControlRequired", true)).setMaxResults(1).list();
>>>>>>> 06bfef8cb5fce10d086dcc972502ce9d01560636

        return (searchResult.getTotalNumberOfEntities() > 0);
Solution content
                TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).getField("qualityControlRequired") == null) {
            return false;
        }

        SearchResult searchResult = dataDefinitionService
                .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).find()
                .isEq("technology.id", entityId).isEq("qualityControlRequired", true).setMaxResults(1).list();

        return (searchResult.getTotalNumberOfEntities() > 0);
File
QualityControlService.java
Developer's decision
Combination
Kind of conflict
Method invocation
Variable