Search in sources :

Example 1 with Vehicle

use of com.axelor.apps.fleet.db.Vehicle in project axelor-open-suite by axelor.

the class VehicleController method setVehicleName.

public void setVehicleName(ActionRequest request, ActionResponse response) {
    Vehicle vehicle = request.getContext().asType(Vehicle.class);
    String actualName = Beans.get(VehicleService.class).setVehicleName(vehicle);
    response.setValue("name", actualName);
}
Also used : Vehicle(com.axelor.apps.fleet.db.Vehicle) VehicleService(com.axelor.apps.fleet.service.VehicleService)

Example 2 with Vehicle

use of com.axelor.apps.fleet.db.Vehicle in project axelor-open-suite by axelor.

the class ImportVehicle method importVehicle.

public Object importVehicle(Object bean, Map<String, Object> values) {
    assert bean instanceof Vehicle;
    Vehicle vehicle = (Vehicle) bean;
    final Path path = (Path) values.get("__path__");
    String fileName = (String) values.get("image_fileName");
    if (Strings.isNullOrEmpty(fileName)) {
        return bean;
    }
    final File image = path.resolve(fileName).toFile();
    try {
        final MetaFile metaFile = metaFiles.upload(image);
        vehicle.setImage(metaFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return bean;
}
Also used : Vehicle(com.axelor.apps.fleet.db.Vehicle) Path(java.nio.file.Path) MetaFile(com.axelor.meta.db.MetaFile) IOException(java.io.IOException) MetaFile(com.axelor.meta.db.MetaFile) File(java.io.File)

Aggregations

Vehicle (com.axelor.apps.fleet.db.Vehicle)2 VehicleService (com.axelor.apps.fleet.service.VehicleService)1 MetaFile (com.axelor.meta.db.MetaFile)1 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1