Search in sources :

Example 1 with Company

use of net.parostroj.timetable.model.Company in project grafikon by jub77.

the class LSCompany method createCompany.

public Company createCompany(TrainDiagram diagram) throws LSException {
    Company company = diagram.getPartFactory().createCompany(id);
    company.getAttributes().add(attributes.createAttributes(diagram::getObjectById));
    return company;
}
Also used : Company(net.parostroj.timetable.model.Company)

Example 2 with Company

use of net.parostroj.timetable.model.Company in project grafikon by jub77.

the class EditCompaniesDialog method createNew.

@Override
protected Company createNew(String name) {
    TrainDiagramPartFactory factory = element.getPartFactory();
    Company newCompany = factory.createCompany(factory.createId());
    newCompany.setAbbr(name);
    return newCompany;
}
Also used : Company(net.parostroj.timetable.model.Company) TrainDiagramPartFactory(net.parostroj.timetable.model.TrainDiagramPartFactory)

Example 3 with Company

use of net.parostroj.timetable.model.Company in project grafikon by jub77.

the class CompanyImport method importObjectImpl.

@Override
protected ObjectWithId importObjectImpl(ObjectWithId o) {
    // check class
    if (!(o instanceof Company))
        return null;
    Company importedCompany = (Company) o;
    // check existence
    Company checkedCompany = this.getCompany(importedCompany);
    if (checkedCompany != null) {
        String message = "company already exists";
        this.addError(importedCompany, message);
        log.debug("{}: {}", message, checkedCompany);
        return null;
    }
    // create new company
    Company company = getDiagram().getPartFactory().createCompany(this.getId(importedCompany));
    company.getAttributes().add(this.importAttributes(importedCompany.getAttributes()));
    // add to diagram
    this.getDiagram().getCompanies().add(company);
    this.addImportedObject(company);
    log.trace("Successfully imported company: {}", company);
    return company;
}
Also used : Company(net.parostroj.timetable.model.Company)

Example 4 with Company

use of net.parostroj.timetable.model.Company in project grafikon by jub77.

the class CompanyPM method ok.

@Operation(path = "ok")
public boolean ok() {
    Company company = companyRef.get();
    if (company != null) {
        // write back
        company.setName(ObjectsUtil.checkAndTrim(name.getText()));
        company.setAttribute(Company.ATTR_PART_NAME, ObjectsUtil.checkAndTrim(part.getText()));
        company.setLocale(locale.getValue());
        company.setAbbr(ObjectsUtil.checkAndTrim(abbr.getText()));
    }
    return true;
}
Also used : Company(net.parostroj.timetable.model.Company) Operation(org.beanfabrics.support.Operation)

Example 5 with Company

use of net.parostroj.timetable.model.Company in project grafikon by jub77.

the class StationTimetablesExtractor method getStationTimetables.

public List<StationTimetable> getStationTimetables() {
    List<StationTimetable> result = new LinkedList<>();
    for (Node node : nodes) {
        StationTimetable timetable = new StationTimetable(node.getName());
        timetable.setType(node.getType());
        // regions + company
        Set<Region> regions = node.getRegions();
        if (!regions.isEmpty()) {
            timetable.setRegions(regions.stream().map(RegionInfo::convert).collect(Collectors.toList()));
        }
        Company company = node.getAttribute(Node.ATTR_COMPANY, Company.class);
        if (company != null) {
            timetable.setCompany(CompanyInfo.convert(company));
        }
        // process rows ...
        for (TimeInterval interval : this.collectIntervals(node)) {
            if (techTime || !interval.isTechnological()) {
                timetable.getRows().add(this.createRow(interval));
            }
        }
        result.add(timetable);
    }
    return result;
}
Also used : Company(net.parostroj.timetable.model.Company) TimeInterval(net.parostroj.timetable.model.TimeInterval) Node(net.parostroj.timetable.model.Node) Region(net.parostroj.timetable.model.Region) LinkedList(java.util.LinkedList)

Aggregations

Company (net.parostroj.timetable.model.Company)5 LinkedList (java.util.LinkedList)1 Node (net.parostroj.timetable.model.Node)1 Region (net.parostroj.timetable.model.Region)1 TimeInterval (net.parostroj.timetable.model.TimeInterval)1 TrainDiagramPartFactory (net.parostroj.timetable.model.TrainDiagramPartFactory)1 Operation (org.beanfabrics.support.Operation)1