Package org.libreplan.business.scenarios.entities

Examples of org.libreplan.business.scenarios.entities.Scenario


    public Order convertImportDataToOrder(OrderDTO project,
            boolean importCalendar) {

        String code = getCode(EntityNameEnum.ORDER);

        Scenario current = scenarioManager.getCurrent();

        OrderVersion orderVersion = OrderVersion.createInitialVersion(current);

        Validate.notNull(orderVersion);
View Full Code Here


    private class UsingScenarioManager extends DayAssignmentsState {

        @Override
        List<DayAssignment> calculateAssignments() {
            List<DayAssignment> result = new ArrayList<DayAssignment>();
            Scenario current = Registry.getScenarioManager().getCurrent();
            for (DayAssignment each : dayAssignments) {
                if (each.getScenario() != null
                        && each.getScenario().equals(current)) {
                    result.add(each);
                }
View Full Code Here

        }
    }

    @Override
    public List<SubcontractedTaskData> getAllForMasterScenario() {
        Scenario masterScenario = PredefinedScenarios.MASTER.getScenario();

        List<SubcontractedTaskData> result = new ArrayList<SubcontractedTaskData>();
        for (Order order : masterScenario.getOrders().keySet()) {
            order.useSchedulingDataFor(masterScenario);
            for (OrderElement orderElement : order.getAllOrderElements()) {
                for (TaskElement taskElement : orderElement.getTaskElements()) {
                    if (taskElement.isSubcontracted()) {
                        result.add(((Task) taskElement)
View Full Code Here

    public void loadRequiredData() {
        for (PredefinedScenarios predefinedScenario : PredefinedScenarios
                .values()) {
            if (!scenarioDAO.existsByNameAnotherTransaction(predefinedScenario
                    .getName())) {
                Scenario scenario = createAtDB(predefinedScenario);
                if (predefinedScenario == PredefinedScenarios.MASTER) {
                    mainScenario = scenario;
                }
            }
        }
View Full Code Here

            mainScenario = PredefinedScenarios.MASTER.getScenario();
        }
    }

    private Scenario createAtDB(PredefinedScenarios predefinedScenario) {
        Scenario scenario = predefinedScenario.createScenario();
        for (Order each : orderDAO.getOrders()) {
            scenario.addOrder(each);
        }
        scenarioDAO.save(scenario);
        scenario.dontPoseAsTransientObjectAnymore();
        return scenario;
    }
View Full Code Here

    public Scenario findByName(String name) throws InstanceNotFoundException {
        if (StringUtils.isBlank(name)) {
            throw new InstanceNotFoundException(null, Scenario.class.getName());
        }

        Scenario scenario = (Scenario) getSession().createCriteria(
                Scenario.class).add(
                Restrictions.eq("name", name.trim()).ignoreCase())
                .uniqueResult();

        if (scenario == null) {
View Full Code Here

    @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
    @Override
    public boolean thereIsOtherWithSameName(Scenario scenario) {
        try {
            Scenario withSameName = findByName(scenario.getName());
            return areDifferentInDB(withSameName, scenario);
        } catch (InstanceNotFoundException e) {
            return false;
        }
    }
View Full Code Here

    @Autowired
    private IAdHocTransactionService transactionService;

    private Order givenStoredOrderInScenario() {
        Scenario defaultScenario = transactionService
                .runOnAnotherReadOnlyTransaction(new IOnTransaction<Scenario>() {

                    @Override
                    public Scenario execute() {
                        return PredefinedScenarios.MASTER.getScenario();
View Full Code Here

        return ScenarioModelTest.givenStoredOrderInScenario(scenario,
                configurationDAO, orderDAO, sessionFactory);
    }

    private Scenario givenStoredScenario() {
        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        return givenStoredScenario(defaultScenario);
    }
View Full Code Here

        final Object[] objects = transactionService
                .runOnTransaction(new IOnTransaction<Object[]>() {
                    @Override
                    public Object[] execute() {
                        Scenario source = givenStoredScenario();
                        Scenario destination = givenStoredScenario();

                        Order order = givenStoredOrderInScenario(source);
                        return new Object[] { source.getId(),
                                destination.getId(), order };
                    }
                });
        final Order orderAtSource = (Order) objects[2];
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    Order order = orderDAO.findExistingEntity(orderAtSource
                            .getId());
                    Scenario source = scenarioDAO.find((Long) objects[0]);
                    Scenario destination = scenarioDAO.find((Long) objects[1]);

                    assertThat(source.getOrders().size(),
                            equalTo(numOrders + 1));
                    assertThat(destination.getOrders().size(),
                            equalTo(numOrders));

                    transferOrdersModel.getScenarios();

                    transferOrdersModel.setSourceScenario(source);
                    transferOrdersModel.setDestinationScenario(destination);

                    transferOrdersModel.transfer(order);

                    return null;
                } catch (InstanceNotFoundException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    Scenario source = scenarioDAO.find((Long) objects[0]);
                    Scenario destination = scenarioDAO.find((Long) objects[1]);

                    assertThat(source.getOrders().size(),
                            equalTo(numOrders + 1));
                    assertThat(destination.getOrders().size(),
                            equalTo(numOrders + 1));
                    assertNotNull(destination
                            .getOrderVersion((Order) objects[2]));

                    return null;
                } catch (InstanceNotFoundException e) {
                    throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of org.libreplan.business.scenarios.entities.Scenario

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.