• 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.
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.
 #46374  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
 #46378  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?
 #46379  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 !!
 #46407  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
 #46409  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 ?
Last edited by mamad on Sun Jul 29, 2018 9:45 am, edited 1 time in total.
 #46418  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))
 #46421  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) {
            }
        });
    }
}

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.