Comments (5)
I think using the global action logic as-is for Tables, GroupTable etc.. List of actions in CUBA would be a good direction.
A global ImportDataAction
like ExcelAction
or CreateAction
would be the best solution.
Ideally this Action will be easy to implement for component users (devlopers):
<!-- actions -->
<action id="importData" directImport="true" />
...
<!-- buttonsPanel -->
<upload id="importFileUploadBtn" action="mytable.importData" uploadButtonIcon="icons/upload.png"/>
once the file selected and uploaded ...
if directImport == true
**then** will force the upload process by searching for a configuration inside database related to that entity; auto-selecting one and following the process with the import
**else** will show a popup asking the user to select a configuration or create a new one (similar to step2 & step3 of the Wizard)
**exceptions** : Any exception will throw a message to the user
@mariodavid , Do you know if it's possible to create a global Action, and register it to the app? Exactly the same question asked by : https://www.cuba-platform.com/discuss/t/define-global-table-actions/894
Unfortunately today I have to write the code below on almost all my Browses:
class MyEntityBrowse2 extends EntityCombinedScreen {
@Inject
FileUploadField importFileUploadBtn
@Inject
FileUploadingAPI fileUploadingAPI
ImportFileHandler importFileHandler
ImportFileParser importFileParser
@Inject
DataConverterFactory dataConverterFactory
@Inject
DataManager dataManager
@Inject
GenericDataImporterService genericDataImporterService
ImportData importData
@Inject
Metadata metadata
@Inject
Datasource<RouteMgmtType> routeMgmtTypeDs
@Inject
GroupDatasource<RouteMgmtType, UUID> routeMgmtTypesDs;
@Override
void init(Map<String, Object> params) {
importFileHandler = new ImportFileHandler(
importFileUploadBtn: importFileUploadBtn,
fileUploadingAPI: fileUploadingAPI,
dataManager: dataManager
)
importFileParser = new ImportFileParser(
importFileHandler: importFileHandler,
dataConverterFactory: dataConverterFactory
)
importFileHandler.onUploadSuccess {
this.importData = importFileParser.parseFile();
def iConfig = metadata.create(ImportConfiguration)
iConfig.dateFormat = 'dd/MM/yyyy'
iConfig.booleanTrueValue = 'Yes'
iConfig.booleanFalseValue = 'No'
iConfig.entityClass = routeMgmtTypeDs.metaClass.name
iConfig.importAttributeMappers = [new ImportAttributeMapper(
configuration: iConfig,
entityAttribute: 'objectName',
fileColumnNumber: 0,
fileColumnAlias: 'objectName'
)]
def dataImportResult = genericDataImporterService.doDataImport(iConfig, importData)
showNotification(String.format("Successfully imported %d records", dataImportResult.entitiesImportSuccess), NotificationType.TRAY_HTML);
routeMgmtTypesDs.refresh();
}
importFileHandler.onUploadError {
showNotification(formatMessage('fileUploadError'), Frame.NotificationType.ERROR)
}
}
}
from cuba-component-data-import.
As far as I know the using the same way the standard actions are defined is not easily possible.
But that does not really matter.
Joerg created this app component in response to this thread you mentioned: https://github.com/balvi/cuba-component-declarative-controllers
Which will solve the problem even more elegant.
from cuba-component-data-import.
Hi @mariodavid,
The component declarative-controllers is really great, but I'm struggling to make it working on the app: https://github.com/genthalili/cuba-component-data-import/tree/with-import-action-on-browser
Do you know why @Component is never detected by cuba ?
from cuba-component-data-import.
never mind, I found the issue. I see that you already implemented the code, so that's even better
from cuba-component-data-import.
done in #76
from cuba-component-data-import.
Related Issues (20)
- Error initializing application using data-import together with attachable component HOT 1
- Support to stop the loading process on unique violation HOT 1
- initial values for entity attributes HOT 6
- Adding Data Import and Tagging together throws an error HOT 1
- You have attempted to set a value of type class java.lang.String for parameter propertyValue with expected type of class java.lang.Integer from query string HOT 1
- Import configurations, does nothing HOT 1
- CUBA 6.10 support HOT 2
- Unable to import data for complex key entity HOT 3
- MySQLSyntaxErrorException: Unknown column 'ASSOCIATION_LOOKUP_ATTRIBUTE' in 'field list' HOT 2
- CUBA 7 support HOT 1
- Import Wizard cannot save Unique Configuration with reuse = true
- Unable to use Excel file for DataImportAPI HOT 1
- Contraint violation HOT 1
- Data Import fails with Unique Configuration: Update and association attribute binding HOT 1
- Transient fields with only a getter are trying to be imported HOT 1
- GuiDevelopmentException: Property 'isColumnRequired' is not found in entity 'ddcdi$ImportAttributeMapper' HOT 1
- Issue with number fields HOT 1
- Bug in the DataImportAPI.java
- unique configuration with composition
- Setting Entity Attribute to next running number
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuba-component-data-import.