Search in sources :

Example 1 with TypeInfoResult

use of org.kie.workbench.common.screens.datamodeller.model.TypeInfoResult in project kie-wb-common by kiegroup.

the class DataModelerServiceImpl method loadJavaTypeInfo.

public TypeInfoResult loadJavaTypeInfo(final String source) {
    try {
        JavaRoasterModelDriver modelDriver = new JavaRoasterModelDriver();
        TypeInfoResult result = new TypeInfoResult();
        org.kie.workbench.common.services.datamodeller.driver.TypeInfoResult driverResult = modelDriver.loadJavaTypeInfo(source);
        result.setJavaTypeInfo(driverResult.getTypeInfo());
        if (driverResult.hasErrors()) {
            result.setErrors(serviceHelper.toDataModelerError(driverResult.getErrors()));
        }
        return result;
    } catch (Exception e) {
        logger.error("JavaTypeInfo object couldn't be loaded for source: " + source, e);
        throw new ServiceException("JavaTypeInfo object couldn't be loaded for source.", e);
    }
}
Also used : ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) TypeInfoResult(org.kie.workbench.common.screens.datamodeller.model.TypeInfoResult) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ModelDriverException(org.kie.workbench.common.services.datamodeller.driver.ModelDriverException) ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) FileAlreadyExistsException(org.uberfire.java.nio.file.FileAlreadyExistsException)

Example 2 with TypeInfoResult

use of org.kie.workbench.common.screens.datamodeller.model.TypeInfoResult in project kie-wb-common by kiegroup.

the class DataModelerScreenPresenter method checkDirtyAndSaveFile.

private void checkDirtyAndSaveFile() {
    final JavaTypeInfoImpl newTypeInfo = new JavaTypeInfoImpl();
    if (isDirty()) {
        if (context.isEditorChanged()) {
            newTypeInfo.setPackageName(context.getDataObject().getPackageName());
            newTypeInfo.setName(context.getDataObject().getName());
            saveFile(newTypeInfo);
        } else {
            view.showLoading();
            modelerService.call(new RemoteCallback<TypeInfoResult>() {

                @Override
                public void callback(TypeInfoResult typeInfoResult) {
                    view.hideBusyIndicator();
                    if (!typeInfoResult.hasErrors() && typeInfoResult.getJavaTypeInfo() != null) {
                        newTypeInfo.setPackageName(typeInfoResult.getJavaTypeInfo().getPackageName());
                        newTypeInfo.setName(typeInfoResult.getJavaTypeInfo().getName());
                        saveFile(newTypeInfo);
                    } else {
                        saveFile(null);
                    }
                }
            }).loadJavaTypeInfo(getSource());
        }
    } else {
        saveFile(null);
    }
}
Also used : JavaTypeInfoImpl(org.kie.workbench.common.services.datamodeller.core.impl.JavaTypeInfoImpl) TypeInfoResult(org.kie.workbench.common.screens.datamodeller.model.TypeInfoResult) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Aggregations

TypeInfoResult (org.kie.workbench.common.screens.datamodeller.model.TypeInfoResult)2 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)1 ServiceException (org.kie.workbench.common.screens.datamodeller.service.ServiceException)1 JavaTypeInfoImpl (org.kie.workbench.common.services.datamodeller.core.impl.JavaTypeInfoImpl)1 ModelDriverException (org.kie.workbench.common.services.datamodeller.driver.ModelDriverException)1 JavaRoasterModelDriver (org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver)1 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)1