Page 1 of 1

Build OpenKM GWT failed when i try to create my own database table

PostPosted:Wed Jul 25, 2018 10:35 am
by mamad
Hi guys,
According to what is sayed in OpenKM 6.3-CE documentation , i try to connect to a database table but when i use the following code , openkm cant be compiled and says "BUILD FAILURE".
this the code i use inside a java file :
Code: Select all
for (DatabaseMetadataValue dmv : DatabaseMetadataDAO.executeValueQuery(DatabaseMetadataUtils.buildQuery("country", "", "$country_name"))) {
    Window.alert(dmv.toString();
    }
and this a summary of console log :
Code: Select all
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OpenKM Web Application 6.3.7-DEV
[INFO] ------------------------------------------------------------------------
.
.
.
.
[INFO] --- gwt-maven-plugin:2.4.0:compile (default-cli) @ openkm ---
[INFO] Compiling module com.openkm.frontend.Main
[INFO]    Validating newly compiled units
[INFO]       Ignored 6 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    [ERROR] Errors in 'file:/home/openkm/Development/workspace/openkm/src/main/java/com/openkm/extension/frontend/client/DBTest.java'
[INFO]       [ERROR] Line 39:  The import com.openkm.core.DatabaseException cannot be resolved
[INFO]       [ERROR] Line 40:  The import com.openkm.dao.DatabaseMetadataDAO cannot be resolved
[INFO]       [ERROR] Line 41:  The import com.openkm.dao.bean.DatabaseMetadataValue cannot be resolved
[INFO]       [ERROR] Line 42:  The import com.openkm.util.DatabaseMetadataUtils cannot be resolved
[INFO]       [ERROR] Line 64:  DatabaseMetadataValue cannot be resolved to a type
[INFO]       [ERROR] Line 64:  DatabaseMetadataDAO cannot be resolved
[INFO]       [ERROR] Line 64:  DatabaseMetadataUtils cannot be resolved
[INFO]       [ERROR] Line 68:  DatabaseException cannot be resolved to a type
[INFO]       [ERROR] Line 73:  DatabaseMetadataValue cannot be resolved to a type
[INFO]       [ERROR] Line 73:  DatabaseMetadataDAO cannot be resolved
[INFO]       [ERROR] Line 77:  DatabaseException cannot be resolved to a type
[INFO]    [ERROR] Cannot proceed due to previous errors
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 41.321 s
[INFO] Finished at: 2018-07-25T11:17:50+02:00
[INFO] Final Memory: 23M/174M
[INFO] ------------------------------------------------------------------------
.
.
.
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Wed Jul 25, 2018 3:02 pm
by lnovoa
Hi!,

What you want to do is a bit weird ... but if we go to the code you need a parenthesis in the alert and the loop should go in a try catch.
The errors that appear to you, are not recognizing the classes ...

Do you have well-configured libraries with maven?
Surely you do not have a red code for the errors?

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Wed Jul 25, 2018 4:28 pm
by mamad
I just want to test the capability of creating database tables in openkm and i just copy and paste the above code from openkm 6.3 CE documentations website(from this link: https://docs.openkm.com/kcenter/view/ok ... ables.html ).I don't know why it is weird for you !
parenthesis was missed when i copy and paste the code here and it exists in my real code
Also i have used Try and Catch block in my code (if you see my log,DatabaseException in line 39 is exactly related to using Database Exception in catch block !)
Currently im using the pre-configured environment (ova file) so i think the maven is configured before and for your assurance i should say there is no syntax error or red line in my code !!

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Wed Jul 25, 2018 5:06 pm
by lnovoa
Ok perfect, and have you tried doing a maven clean or maven install project?
You may, by doing this, import the classes that you do not recognize

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Thu Jul 26, 2018 7:16 am
by mamad
I try both Maven clean and Maven install but Maven Install failed too
Also I have added import lines before :| :(

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Thu Jul 26, 2018 7:44 am
by lnovoa
Try resetting the OVA again. This is well configured ready to develop

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Fri Jul 27, 2018 10:42 am
by mamad
Currently i'm using OVA
Also resetting it did not solve the problem !

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Fri Jul 27, 2018 10:43 am
by mamad
Does anyone else has any idea ؟؟؟ :roll: :roll: :roll:

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Sat Jul 28, 2018 8:11 am
by jllort
Obviously, you have not understood how it works GWT, consider that GWT in compilation time, converts JAVA code into javascript ( but can not doing it for any class in the world ).

Into the Main.gwt.xml there are set the packages what are included into the GWT compilation scope. For accessing to the DatabaseMetadataDAO what is a class into the OpenKM core should be done across a Servlet.

Take a look at DatabaseMetadataServlet.java class , you should use the class OKMDatabaseMetadataServiceAsync into the GWT code. Below some URL:

https://github.com/openkm/document-mana ... Async.java
https://github.com/openkm/document-mana ... rvlet.java

Finally I think here you will find a complete sample about it:
https://docs.openkm.com/kcenter/view/ok ... gwt-).html

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Sun Jul 29, 2018 5:05 am
by mamad
OK ,OK, Thank you.
Please just tell me According to what is said in this link :
jllort wrote: Sat Jul 28, 2018 8:11 am https://docs.openkm.com/kcenter/view/ok ... gwt-).html
where i should place GWTExtendedSecurity.java and Example.java files ? i mean in which packages ?

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Sun Jul 29, 2018 8:02 am
by jllort
These will work into com.openkm.frontend.client package ( or a child into ). Everything into com.openkm.frontend are GWT based classes.

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Sun Jul 29, 2018 12:27 pm
by mamad
i create both java file inside package com.openkm.frontend.client;
BUTT Class Example.java file has a lot of errors and cant be compiled :
for example at line 5:
public test() {
.
.
what is this ? its a constructor ? or it is just a method ? if it is a method why it has not any return type ? if its a constructor why it has different name with class ?
Or at line 8 :
Multiple markers at this line
- AsyncCallback cannot be resolved to a type
- The method getNextSequenceValue(String, String, AsyncCallback<Double>) in the type OKMDatabaseMetadataServiceAsync is
not applicable for the arguments (String, String, new AsyncCallback<Double>(){})


Guys are you sure you test this codes before ???
(i'm using openkm 6.3-CE in linux mint (OVA))

Re: Build OpenKM GWT failed when i try to create my own database table

PostPosted:Mon Jul 30, 2018 6:39 am
by jllort
Was only two few error in the class, the method test should return void and wrong variable name "security" bad written, nothing else ( I have corrected in the documentation ). The error you have might be are for bad importing packages, I shared here the full class Example.java
Code: Select all
package com.openkm.frontend.client;

import java.util.List;
import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.openkm.extension.frontend.client.bean.GWTExtendedSecurity;
import com.openkm.frontend.client.extension.comunicator.GeneralComunicator;
import com.openkm.frontend.client.service.OKMDatabaseMetadataService;
import com.openkm.frontend.client.service.OKMDatabaseMetadataServiceAsync;

public class Example {
    private final OKMDatabaseMetadataServiceAsync metadataService = (OKMDatabaseMetadataServiceAsync) GWT.create(OKMDatabaseMetadataService.class);

    public void test() {
        // get sequence
        metadataService.getNextSequenceValue("table_name", "col_name" , new AsyncCallback<Double>() {
            @Override
            public void onSuccess(Double result) {
                int value = result.intValue();
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });

        // create value
        final GWTExtendedSecurity security = new GWTExtendedSecurity();
        security.setUuid("some uuid");
        security.setName("some name");
        security.setType(GWTExtendedSecurity.TYPE_ROLE);
        security.setRealTable(GWTExtendedSecurity.MV_TABLE_NAME);
        metadataService.createValue(security.restoreToMap(), new AsyncCallback<Double>() {
            @Override
            public void onSuccess(Double result) {
                // created
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });

        // Execute query
    String filter = "$" + GWTExtendedSecurity.MV_COLUMN_NAME_UUID + "='some uuid'";
        metadataService.executeValueQuery(GWTExtendedSecurity.MV_TABLE_NAME, filter, "", new AsyncCallback<List<Map<String,String>>>() {
            @Override
            public void onSuccess(List<Map<String, String>> result) {
                if (result.size() > 0) {
                    GWTExtendedSecurity security = new GWTExtendedSecurity();
                    security.loadFromMap(result.get(0));
                }
            }

            @Override
            public void onFailure(Throwable caught) {
                GeneralComunicator.showError("executeValueQuery", caught);
            }
        });

        // Update value
        security.setName("some name changed");
        metadataService.updateValue(security.restoreToMap(), new AsyncCallback<Object>() {
            @Override
            public void onSuccess(Object result) {
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });

        // Delete value
        metadataService.deleteValue(security.restoreToMap(), new AsyncCallback<Object>() {
            @Override
            public void onSuccess(Object result) {
            }

            @Override
            public void onFailure(Throwable caught) {
            }
        });
    }
}