use of com.axelor.meta.db.MetaFile in project axelor-open-suite by axelor.
the class ExcelReaderService method initialize.
@Override
public boolean initialize(MetaFile input, String separator) {
if (input == null) {
return false;
}
File inFile = MetaFiles.getPath(input).toFile();
if (!inFile.exists()) {
return false;
}
try {
FileInputStream inSteam = new FileInputStream(inFile);
book = new XSSFWorkbook(inSteam);
if (book.getNumberOfSheets() == 0) {
return false;
}
formatter = new DataFormatter();
} catch (IOException e) {
e.printStackTrace();
return false;
}
return true;
}
use of com.axelor.meta.db.MetaFile in project open-platform-demo by axelor.
the class ProductImport method importProduct.
public Object importProduct(Object bean, Map context) {
Product product = (Product) bean;
final Path path = (Path) context.get("__path__");
try {
final Path image = ImportUtils.findByFileName(path.resolve(PRODUCT_IMAGES_DIR), product.getCode());
if (image != null && image.toFile().exists()) {
final MetaFile metaFile = Beans.get(MetaFiles.class).upload(image.toFile());
product.setImage(metaFile);
}
} catch (Exception e) {
// ignore
}
return product;
}
Aggregations