Webratio with Git support

10 Dec '11, 10:30 AM
15,572 Views
No Forum Badges

Hi, is it possible to use Git repositories (like GitHub) in WebRatio tool? And if it is, what should I do to start using Git? Thanks in advance for help.

 
x 1
Follow
Answer Answer at this question and get points!
Forum Starter - Level 2

Hi!

You can try to use a Script Unit in order to accomplish your task.

There are some useful articles in our WebRatio Wiki:

  • Getting started with the Script unit
  • Getting started with Groovy
  • Script units accessing database
  • Querying with Hibernate

Let's make a simple example on how you can write the Groovy script to perform your task. Suppose you have an uploaded file and you want to save the content of this file inside one Entity of your Data Model. In particular consider that each row of the uploaded file has a value and you want to save this value in the attribute "Value" of your Entity (i.e. "LogRecord").

So your script should perform these tasks:

1) Take as input the uploaded file

2) Read the uploaded file

3) Parse each row of the file

4) Save the content of each row in the entity LogRecord

First of all you have to define the input of the script (i.e. the uploaded file):

#input RTXBLOBData file

Then let's import some packages that you will use

import java.io.*
import com.webratio.webapp.LogRecord

The last import is the class which represents the JavaBean of the entity "LogRecord"

Now you have to recover the database session

/*Recover db session
Suppose that our database id is "db1"
*/
def dbId = "db1"
def session = getDBSession(dbId)

At this point you have to create a File object from the input file, read it and save its content to the entity ""LogRecord""

 try
 {
/*Create temporary file to parse from RTXBLOBData*/
def tempFile=new File(file.getName()); 
InputStream inputStream= file.openFileInputStream() 
OutputStream outStream=new FileOutputStream(tempFile);
def buf=new byte[1024]
def len
while((len=inputStream.read(buf))>0)
{
    outStream.write(buf,0,len)
}

Now you have the temporary File object that can be read row by row

 /*Read temporary file row by row until !EoF*/
tempFile.eachLine{i->
    /*Parse your file row*/
    In our case each row has only one value 
    /*Save data*/
    //Create an instance of our entity
    LogRecord log = new LogRecord()
    //Use the setter method exposed by the JavaBean to set the value
    log.setValue(i)
    //Save the data in the entity
    session.save(log)
}
//Close the InputStream and OutputStream instances in order to release any system resources associated with the streams
outStream.close()
inputStream.close()
//Perform the commit of the database session in order to physically write the changes on the database
commit(session)

  }catch(Exception e){
println(e.getMessage())}

   
x 0
No Forum Badges

Hi,

This question about Git was two years ago. 

Any update? It would be great using GitHub or Bitbucket with webratio.

Is there any plan to include Git in your product roadmap?

 
x 1
Answer at this question and get points!

Related questions

500 error with WebRatio BPM A Commercial Hosting Service for the publication of a Website? Any sample deployment application not deploying properly Automatization of deployment AWS Elastic Beanstalk y Webratio Build Project. Only files for compilation .class Can I deploy an application to the cloud using RightScale and/or Scalr? Can I integrate Amazon S3 and/or Amazon CloudFront? Can I use Git with Webratio Cannot invoke method selectSingleNode() on null object Code is exceeding the 65535 bytes limit error on JBOSS Deploy de proyecto en HTTPS Deploying to CloudBees Deploy web project da riga di comando Error deploying Bookstore sample to cloud Error deploying WAR against to JBOSS Error testing mobil app in android From BPM to WebProject - BUILD FAILED "Generation Error" with Generate and Run Hacer pruebas unitarias y de integración / Unit Test in WebRatio Hide form until a flow is triggered How i can reuse modules in multiple projects? How to accelerate the generation process? How to avoid language selection automatically according to the browser? how to delete this error? How to disble derby database? how to fix invalid checkcode invio mail fallito Is there any custom unit store or repository? Do you create/sell custom units? JSP/DO issues on Tomcat 5.5 (Ubuntu) mandatory control code parameter is missing Page Home - First time the Project Web begins Problema al generar y ejecutar proyecto Problema ¨HTTP Status 404" problem on first deploy with webratio Problem with application runnung Problem with execution of webratio Project generation best practices redeployCheckInterval property REST connection and Mobile App deploy Root Context & Enterprise Project Sample web application Sincronizar Proyectos en SVN Some hint before I generate and deploy a webapp on a 64-bit windows system? Start Job when WebApp starts Tomcat external session store and WebRatio webapp. Unable to compute the controller URL(s) for applicationUnable to compute the controller URL(s) for application having status PROVISIONING Unable to find Cloud free function Unspecified BPM Engine Database Use Running profile en project Webratio Add-ons no permite login