Asqatasun API usage


#1

Hello! I would like to use Asqatasun API and i wonder if there is documentation about the functions that the API provides, so i can understand their functionality.


#2

Hi @nivak91,
What do you mean by Asqatasun API ?


#3

If you fork the project from github and look at the files there is a file named asqatasun-api (Asqatasun/engine/asqatasun-api) where you can find several java interfaces you can use that provide the asqatasun engine functionality for developers, but you can understand what each function of these interfaces does only by the name and i would like some more information of their usage.


#4

Ok you talk about engine/asqatasun-api/ directory.
@koj can help you, but tell us what you trying to do?

engine/asqatasun-api/src/main/java/org/asqatasun
β”œβ”€β”€ analyser
β”œβ”€β”€ consolidator
β”œβ”€β”€ contentadapter
β”œβ”€β”€ contentloader
β”œβ”€β”€ crawler
β”œβ”€β”€ dialect
β”œβ”€β”€ entity
β”œβ”€β”€ exception
β”œβ”€β”€ factory
β”œβ”€β”€ nomenclatureloader
β”œβ”€β”€ parameterization
β”œβ”€β”€ processor
β”œβ”€β”€ ruleimplementation
β”œβ”€β”€ ruleimplementationloader
β”œβ”€β”€ rules
β”œβ”€β”€ scenarioloader
β”œβ”€β”€ service
└── util

#5

I’m trying to use the API to make a simple program that will produce reports for a small number of given URL’s, and for a referential or some tests that i will give as an input, so i try to understand what each function does.


#6

Hi @nivak91,

The branch you mention (rest-api) is under heavy development. But if you feel a bit brave you may start using it :wink:

Here is an early seed of documentation of Rest-API.

Once you get into the Swagger-UI, things should be clearer. Feel free to ask questions !


#7

Ξ€hanks a lot i appreciate the help. I will check these and probably come back with new questions!


#8

Hi again @mfaure. I tried to follow the documentation instructions, so i changed my local branch to rest-api and i tried to build the project, but i get the following error:

[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.asqatasun:engine:4.1.0-SNAPSHOT (/home/vak/Asqatasun/engine/pom.xml) has 1 error
[ERROR]     'modules.module[17]' specifies duplicate child module asqatasun-web @ line 32, column 17

Do you know what is wrong? Also i would like to ask you what exactly should i do for this instruction:β€œadjust SQL credentials (yes, do it, especially if you already had an Asqatasun before, change the DB name)” Which file and what exactly should i change? Thanks!


#9

removes one of the two lines into /engine/pom.xml file
<module>asqatasun-web</module>

if successful compilation, you can do a pull request on Github.


:gift: the git squad has been contacted… :wink:


#10

i erased the line and i have a new error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 
(default-compile) on project asqatasun-web: 
Fatal error compiling: invalid target release: 1.8 -> [Help 1]

#11

Hi @nivak91,

Can you tell us what is the result of the following command lines ?

java -version
javac -version

I think this branch must be compiled with Java 8.
@mfaure that’s right ?


but with java 8, I have another error.

I do this:

wget https://raw.githubusercontent.com/Asqatasun/Asqatasun/master/web-app/tgol-resources/src/main/resources/conf/asqatasun.conf                     
cat asqatasun.conf | grep jdbc 
sed -i -e "s#\$SQL_SERVER_URL#localhost#"      asqatasun.conf 
sed -i -e "s#\$USER#asqatasun#"                asqatasun.conf 
sed -i -e "s#\$PASSWORD#asqatasun#"            asqatasun.conf 
sed -i -e "s#\$DATABASE_NAME#asqatasun5api#"   asqatasun.conf 
cat asqatasun.conf | grep jdbc 
 
mkdir -p /tmp/asqatasun5api/conf
mv    -v asqatasun.conf /tmp/asqatasun5api/conf/asqatasun.properties 
 
git clone git@github.com:Asqatasun/Asqatasun.git
cd  Asqatasun
git checkout rest-api
mvn -DconfDir=/tmp/asqatasun5api clean install

I’ve got the following error:

 Error creating bean with name 'flyway' 
 Unable to scan for SQL migrations in location: classpath:sql/automated/mainOnly
----------------------
18:53:06.510 [main] INFO  o.f.c.i.dbsupport.DbSupportFactory - Database: jdbc:mysql://localhost:3306/asqatasun5api?autoReconnect=true (MySQL 5.7)
18:53:06.527 [main] WARN  o.s.w.c.s.GenericWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/asqatasun/rest/config/PersistenceConfig.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to scan for SQL migrations in location: classpath:sql/automated/mainOnly
18:53:06.534 [main] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/asqatasun/rest/config/PersistenceConfig.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Unable to scan for SQL migrations in location: classpath:sql/automated/mainOnly
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)

#12

I have another one problem. I try to get an audit with the following code:

AuditServiceImpl Test = new AuditServiceImpl();
ParameterDataServiceImpl param_service = new ParameterDataServiceImpl();
Set Set = param_service.getDefaultParameterSet();
Audit audit1 = Test.auditPage(β€œThe_URL”, Set);

and i get: Exception in thread β€œmain” java.lang.NullPointerException.
What could i do to get a parameter set?


#13

Hi,

I think this problem is in relation with the previous one.
Flyway is supposed to initialize the database with all the expected default data.
The default parameter set is extracted/loaded from these data, but if there are missing, it cannot work.
I’m currently working on this branch, but i’ve been busy lately.

Hopefully, I’ll be able to get some time at the end of the next week to try to clean it up, and make it work.

Regards

Koj


#14

Hi,

I think I understand your problem now.
The application is strongly coupled with Spring, which means it’s hard to instanciate β€œmanually” a context.
Spring will help us to inject all the dependencies, on runtime, based on interfaces implementations loaded at this time.
By bypassing Spring to set-up the context, you have to fully manage and instanciate the dependencies.
It can be a good exercise to understand how the application works, but it can be long and painful :wink: You have to search all @service and @Component annotated classes, and instanciate them.
Then, the @Autowired occurrences in the code, and ensure the injection of the services.
The other solution is to wait a couple of weeks to give me some time to provide a clean version, and then, focus on the API defintion.

Regards

Koj


#15

Ok thanks a lot @koj, please let me know when it is ready! For now
another issue occured. I had installed asqatasun and it worked properly and now i get http status 404 when trying to access http://localhost:8080/asqatasun/ …Any ideas?


#16

Hi @nivak91

Could you create a new thread (as this subject will different) and add the relevant logs from /var/log/asqatasun/asqatasun.log and /var/log/tomcat/catalina.out.

Thanks in advance :slight_smile: