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

Problems with installing OpenKM? No problemo, the solution is closer than you think.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Wed Jul 25, 2018 10:35 am

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

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

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

Post by lnovoa » Wed Jul 25, 2018 3:02 pm

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?

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Wed Jul 25, 2018 4:28 pm

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 !!

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

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

Post by lnovoa » Wed Jul 25, 2018 5:06 pm

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

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Thu Jul 26, 2018 7:16 am

I try both Maven clean and Maven install but Maven Install failed too
Also I have added import lines before :| :(

lnovoa
Expert Boarder
Expert Boarder
Posts: 95
Joined: Tue Mar 27, 2018 8:00 am

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

Post by lnovoa » Thu Jul 26, 2018 7:44 am

Try resetting the OVA again. This is well configured ready to develop

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Fri Jul 27, 2018 10:42 am

Currently i'm using OVA
Also resetting it did not solve the problem !

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Fri Jul 27, 2018 10:43 am

Does anyone else has any idea ؟؟؟ :roll: :roll: :roll:

jllort
Moderator
Moderator
Posts: 10243
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

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

Post by jllort » Sat Jul 28, 2018 8:11 am

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

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Sun Jul 29, 2018 5:05 am

OK ,OK, Thank you.
Please just tell me According to what is said in this link :
where i should place GWTExtendedSecurity.java and Example.java files ? i mean in which packages ?
Last edited by mamad on Sun Jul 29, 2018 9:45 am, edited 1 time in total.

jllort
Moderator
Moderator
Posts: 10243
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

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

Post by jllort » Sun Jul 29, 2018 8:02 am

These will work into com.openkm.frontend.client package ( or a child into ). Everything into com.openkm.frontend are GWT based classes.

mamad
Senior Boarder
Senior Boarder
Posts: 66
Joined: Mon Jun 25, 2018 5:13 am

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

Post by mamad » Sun Jul 29, 2018 12:27 pm

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))

jllort
Moderator
Moderator
Posts: 10243
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

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

Post by jllort » Mon Jul 30, 2018 6:39 am

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) {
            }
        });
    }
}

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests