Re: Data Loading and Entity Modification

2014-04-03 Thread Youssef Khaye


Le 03/04/2014 21:46, JS a écrit :

Hello,

I have a question about the entity engine in OFBiz, mainly pertaining to how
changes to "entitymodel.xml" and seed data are handled when there is already
data in the entity.

I've done some searches and experimentation on my own to try and determine
this but came up inconclusive results:

1) If more seed data needs to be loaded after the system is already in
production, will the seed data loader skip loading records which are already
in the entity, and only add the new ones? If not, what is the recommended
way to add the new data to the entity if not using the seed data loading
functionality?


when loading data (seed or demo ) from xml file, ofbiz proceed as 
folowing for each xml entry :

create a database record if it does not exists.
if the record exists and has at least one field with diffrenet value it 
make an update operation.

otherwise it does noting for the given xml entry.
for more detail, see create-replace that may change the entity loader 
behavior


2) If a schema change is required (i.e. data type change, column
addition/removal) how do you go about doing this on a system already in
production (which will have existing data), using the entity engine? If it
can't be done with just the entity engine and would require an external DB
tool to do so, how do you ensure that OFBiz's "entitymodel" is back in sync
with the new DB schema?
ofbiz can only add missing tables, fields, contraints, indicies etc... 
to get database schema sync with its entitymodel.


operations like;
removing no more used tables, fileds..
change field type or name ...
should be done by the database administrator.
of course you should update your entity model and make sure it is sync 
with the database schema (look at ofbiz start log if the check-on-start 
is enabled in entity-engiine)



Thanks!
J



--
View this message in context: 
http://ofbiz.135035.n4.nabble.com/Data-Loading-and-Entity-Modification-tp4650171.html
Sent from the OFBiz - User mailing list archive at Nabble.com.




Re: using websocket within ofbiz

2014-04-20 Thread Youssef Khaye

Hi

yes, i hav successfully use websockets to send information to connected 
when some event occures server side.


in details, i used asterisk-java, to interact wieth an servisk server, 
and used websockets to communicate with client browser, to whox coming 
calls for examples.


i used the old apache websocket api, which is deprecated. the new one 
still difficle to make working within ofbiz, i faced sale issues as 
jaccoppo.


hope this help.



Le 17/04/2014 12:48, MelonJaya a écrit :

Hi all,

I've been trying to utilize the websocket in current trunk of ofbiz.
Make new component in hot-deploy, using the exact chat example from tomcat
and include the Java class. It can be compiled and ant start run without
any problem, but my browser console keeps telling me that ws connection
cannot be made.

I have read the discussion from Jacopo in Tomcat mailing list too, tried to
add the listener in web.xml and still my browser cannot make ws connection
to my ofbiz instance.

Have you guys any experience on this issue?

Thanks in advance!
Johnson Chandra





Re: hashtag in request parameters on the url param

2014-04-23 Thread Youssef Khaye

hello,

the hash tag is used in url to point to specific part of a page(bookmark 
or anchor).


so i think it can not be receivied server side but stripped out from the 
url by the navigator (to be confirmed).


hope this help.

Youssef khaye.


Le 23/04/2014 12:43, Jen Sing Choe a écrit :

Hi,
I had tried as below

encode-output="true"
StringUtil.wrapString

i print out the context map.
The value in the context map (requestParameters,parameters) of that
particular property key, is already hashtag removed.

Below are the scenario,
1. create product with productId= ##123##

when click on the EditProduct
catalog/control/EditProduct?productId=##123##
the system cannot find the product
in the browser URL fields, the value are showing the correct value with
hashtag

I had goes trough the below java class, but none are able to explain the
cause of the hashtag
ModelFormField.java
StringUtil.java
UtilHttp.java

Am i missing anything?



On Wed, Apr 23, 2014 at 1:52 PM, Adrian Crum <
adrian.c...@sandglass-software.com> wrote:


Have you tried URL encoding?

Adrian Crum
Sandglass Software
www.sandglass-software.com


On 4/22/2014 9:09 PM, Jen Sing Choe wrote:


Hi,
Had anyone had difficult passing hashtag (#) into the request parameters
as
url param

e.g
myValue#1234

the value stored into the context are myValue
In which the character starting and after hastag are all being removed.






Re: using websocket within ofbiz

2014-04-24 Thread Youssef Khaye

hello;
you need to add following jars to your classpath:
tomcat7-websocket.jar
websocket-api.jar
web.xml
http://java.sun.com/xml/ns/javaee";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd";
  version="3.0"
  metadata-complete="true">


  AsteriskSocket
org.ofbiz.service.asterisk.websocket.AsteriskSocket


  AsteriskSocket
  /ws


you need to copy the .class AsteriskSocket into your webapp dir, i used 
ant jar target to make it.


+value="build/classes/org/ofbiz/service/asterisk"/>
+value="webapp/asterisk/WEB-INF/classes/org/ofbiz/service/asterisk"/>


 
 
 
+
+
+
+
 

look at attachement for the websocket server side implementation

hope this will help you.

Le 24/04/2014 13:40, MelonJaya a écrit :

HI Youssef,

I tried the old deprecated API but still cannot make websocket connection
between browser and server(ofbiz embedded tomcat).
Can you explain more how you do it?

another alternative would be deploy ofbiz to (outside)Tomcat, but I am
stuck too.



On Sun, Apr 20, 2014 at 6:37 PM, Youssef Khaye wrote:


Hi

yes, i hav successfully use websockets to send information to connected
when some event occures server side.

in details, i used asterisk-java, to interact wieth an servisk server, and
used websockets to communicate with client browser, to whox coming calls
for examples.

i used the old apache websocket api, which is deprecated. the new one
still difficle to make working within ofbiz, i faced sale issues as
jaccoppo.

hope this help.



Le 17/04/2014 12:48, MelonJaya a écrit :

  Hi all,

I've been trying to utilize the websocket in current trunk of ofbiz.
Make new component in hot-deploy, using the exact chat example from tomcat
and include the Java class. It can be compiled and ant start run without
any problem, but my browser console keeps telling me that ws connection
cannot be made.

I have read the discussion from Jacopo in Tomcat mailing list too, tried
to
add the listener in web.xml and still my browser cannot make ws connection
to my ofbiz instance.

Have you guys any experience on this issue?

Thanks in advance!
Johnson Chandra




/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ofbiz.service.asterisk.websocket;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.atomic.AtomicInteger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
import org.apache.catalina.websocket.WsOutbound;
import org.apache.commons.lang3.StringEscapeUtils;
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilValidate;
import org.ofbiz.service.asterisk.AsteriskServiceProvider;


@SuppressWarnings("deprecation")
public class AsteriskSocket extends WebSocketServlet {
public static String module = AsteriskSocket.class.getName();
private static final long serialVersionUID = 1L;
private final AtomicInteger sessionId = new AtomicInteger(0);
@Override
public void init() throws ServletException {
super.init();
asp.setSockets(sessions);
}

@Override
protected StreamInbound createWebSocketInbound(String subProtocol,
HttpServletRequest request) {
return new AsteriskSocketSession(sessionId.incrementAndGet());
}

public final class AsteriskSocketSession extends MessageInbound {
public final int id;
public AsteriskSocketSession(int id) {
super();
this.id = id;
}

public int getId() {
return id;
}


@Override
protected void onBinaryMessage(ByteBuffer message) throws IOException {
}

@Override
protected void onTextMessage(CharBuffer msg

Re: OFBIZ-5473 Expense Declaration

2014-04-29 Thread Youssef Khaye

it seems to be an interesting feature.
meanwhile,

the pdf contains some exception stack trace.
item date may be out of the report from-thru interval.
edit button does not allow modifying an item.

in some case company may have rules limiting expense with maximum amount 
(per expense type),

you may include this feature in the futre evolutions.

good works continue

Le 28/04/2014 14:58, Pierre Smits a écrit :

Hi All,

Today we implemented the first release of an application expressing our
viewpoint on how to do (travel) expense reporting with OFBiz in our demo
environment.

With this (reference) app users can register new expense reports and
declare expenses for travel, daily allowances, etc. The user can also
generate a pdf of the expense report.

*Creating a new expense report*
Based on the setting of the application area (type) of the expense report,
the user can select the appropriate application from a drop-down which will
automatically determine the approver. In our demo setup this can be seen
with application area 'project' and project 'Implement new affiliate site',
or with marketing campains.

*Adding expenses to a report*
The user can add new expense items to a report (with status 'not ready for
review'). Based on configuration aspects of the selected expense product
fields for quantity, price, tax will be shown.

You can have a look at https://online.orrtiz.com/essterr/control/main and
login with:

userId: *Traveler*

password: *orrtiz*

tenantId: *4proserve*



We invite you to have a look and review our approach and discuss
requirements and wishes on the issue created for this
(OFBIZ-5473
).

Should you have any questions and/or remarks feel free to ask and/or
comment on the issue itself, here or via an email directly to me.

Regards,

Pierre Smits

*ORRTIZ.COM *
Services & Solutions for Cloud-
Based Manufacturing, Professional
Services and Retail & Trade
http://www.orrtiz.com





Re: Non static java method call in ftl

2014-05-14 Thread Youssef Khaye
In general, to call a non static java method you should have an instance 
from its class.

for example
${screens.render("component://common/widget/CommonScreens.xml#cctypes")}
in our context  we have an object called "screens"  wich is an instance 
of ScreenRenderer class.

with that object we can call non static method  render:
public String render(String combinedName)
hope this help.

youssef.

Le 14/05/2014 11:22, Ramkrishna Swamy a écrit :

Hi User,

Is there any way to call non static java method in ftl?






Re: is delegator.storeAll() always committed?

2014-07-21 Thread Youssef Khaye

hi Marc,
here is this the definition of "use-trasaction"
<<
If set to true and there is no transaction already in place
 the Service Engine will begin one. If set to false or there is a
 transaction already in place the Service Engine will do
 nothing (this also means that if set to false and a
 transaction is already in place it will do nothing).
>>
from that definition we are not sure that there is no transction for 
current service.


what is the problème with your output ?
did u check table to see if record was realy deleted or not ?
I used to suspend a Tx (TransactionUtil.suspend() return current Tx if 
there is one) and then call resume after my code.


  +  Transaction currentTx = TransactionUtil.suspend();
boolean transactionBegan = TransactionUtil.begin();
Debug.logVerbose("transactionBegan = "+transactionBegan, 
MODULE);

delegator.removeByCondition("TableA", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("transactionBegan = "+transactionBegan, 
MODULE);

Debug.logVerbose("Deleting from tableA", MODULE);

transactionBegan = TransactionUtil.begin();
delegator.removeByCondition("TableB", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("Deleting from tableB", MODULE);
+ if(UtilValidate.isNotEMpty(currentTx))
+   TransactionUtil.resume(currentTx);

Le 21/07/2014 14:34, Marc von der Brüggen a écrit :

Hi,

I disabled the service's transaction

use-transaction="false"

and handle it manually. It seems to be fine, now.

boolean transactionBegan = TransactionUtil.begin();
Debug.logVerbose("transactionBegan = "+transactionBegan, 
MODULE);

delegator.removeByCondition("TableA", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("transactionBegan = "+transactionBegan, 
MODULE);

Debug.logVerbose("Deleting from tableA", MODULE);

transactionBegan = TransactionUtil.begin();
delegator.removeByCondition("TableB", completeCondition);
TransactionUtil.commit(transactionBegan);
Debug.logVerbose("Deleting from tableB", MODULE);

My output is:
transactionBegan = true
transactionBegan = true
Deleting from tableA
Deleting from tableB

Do I have to close the transaction after a commit and what is the 
correct way?
Call TransactionUtil.suspend() and 
TransactionUtil.cleanSuspendedTransactions()?


Thank you very much!


Kind regards
Marc



Am 15.07.2014 11:51, schrieb Nicolas Malin:

Hi,

Le 15/07/2014 10:12, Marc von der Brüggen a écrit :

Hello Nicolas,

thank you very much for your help.

I tried it:

Debug.logVerbose("### Store List Prices 
("+productPrices.size()+") ###", MODULE);

Transaction transaction = null;
transaction = TransactionUtil.suspend();
boolean transactionBegan = TransactionUtil.begin();
delegator.storeAll(productPrices);
TransactionUtil.commit(transactionBegan);
TransactionUtil.resume(transaction);
TransactionUtil.commit();
Debug.logVerbose("### List Prices Stored 
("+productPrices.size()+") ###", MODULE);


but the output is still the same:

 [java] 2014-07-15 09:58:54,831 (default-invoker-Thread-6) [ 
OfbizPriceImporter.java:688:DEBUG] ### Store List Prices (1234) ###
 [java] 2014-07-15 09:58:54,831 (default-invoker-Thread-6) [
TransactionUtil.java:348:WARN ] No transaction in place, so not 
suspending.
I'm really surprising on that ! If you haven't transaction available, 
your service don't open a transaction or you have disable on the 
entity engine your transaction manager.

In this case just :

boolean transactionBegan = TransactionUtil.begin();
delegator.storeAll(productPrices);
TransactionUtil.commit();

works.
[java] 2014-07-15 09:58:55,990 (default-invoker-Thread-6) [ 
TransactionUtil.java:210:WARN ] [TransactionUtil.commit] Not 
committing transaction, status is No Transaction (6)
 [java] 2014-07-15 09:58:55,990 (default-invoker-Thread-6) [ 
OfbizPriceImporter.java:696:DEBUG] ### List Prices Stored (1234) ###



Kind regards
Marc


Am 10.07.2014 15:12, schrieb Nicolas Malin:

Ok I understand.

If you run a commit in your code at the service end, the 
transaction has been already commited


So, open a new transaction like this  :

Transaction transaction = null;
try {
transaction = TransactionUtil.suspend();
boolean transactionBegan = TransactionUtil.begin();
delegator.storeAll(listOfGenericValues);
TransactionUtil.commit(transactionBegan );
TransactionUtil.resume(transaction);
} catch (YourExceptionLevel e) {
Debug.logError(e, module);
TransactionUtil.rollback();
TransactionUtil.resume(transaction);
}


Le

Re: Processing entries in custom table

2014-08-03 Thread Youssef Khaye

you may use service semaphore (with fail type) to achieve this.
When the service is invoked it will create a kind of lock (an entry
with the service name as a value in the semaphore table), if the lock 
already exists (because of old one still running), the new service will 
fails.


hope this help.

Le 03/08/2014 18:14, Vyom Jain a écrit :

Hello Everyone,

I've a requirement to process a custom table which is populated by an
external application. It is required that entries are processed as fast as
possible.
To achieve this a service has been written which is scheduled to execute
every 5 seconds (done via changing configuration in serviceengine.xml &
temporal expressions).

While this approach works well, I've noticed that at times multiple
instances of service getting scheduled, this probably happens because the
service that was initially scheduled took longer than 5 seconds to
complete. Is there a way I can ensure only 1 instance of the service is
active at any given point in time?

Can anyone suggest a better approach in which job scheduler isn't involved?

I'm using a heavily customized version of OFBiz which is somewhere between
v09.04 & 10.04 and doesn't have the advantages of job scheduler fixes added
in later versions.

--
Vyom





Re: connection to external database: part 2

2014-12-12 Thread Youssef Khaye

I will try to answer, even if i don't understand your use case at 100%

Hi for your second question the answer is no.

For your first question you should show us your entityengine.xml
There is two different cases where  you can use a second database.


Case 1 use a diffrent delegator (from your first post, i think that you 
fill in this case), to get record you should instanciate


a  delegator using the name you declared in entityegine.xml
entity-group-reader="main" entity-eca-reader="main" 
distributed-cache-clear-enabled="false">


datasource-name="localpostgres"/>
datasource-name="localpostgres"/>



entity-group-reader="main" entity-eca-reader="main" 
distributed-cache-clear-enabled="false">




then in your service
delegator = delagtor.geInstance("mysqlDb")
then use the entity API to get record from your DB.


Case 2
In the same delegator you may assign a diffrent dataSource, that point 
to the external DB, to a given package.


entity-group-reader="main" entity-eca-reader="main" 
distributed-cache-clear-enabled="false">



datasource-name="localpostgres"/>
datasource-name="localpostgres"/>


In this case the defeault delegator you get in a service can fetch 
record from any entity in the com.custom package.


Personnaly, I use the first one if I need the external database in 
limited area of my OFBiz.


The second one is suitable if you need to access your external db in 
many areas of your OFBiz



Le 12/12/2014 09:03, i...@agentur-m3.de a écrit :

Hi All!

after setting up the connection with an external database
without errors I have two more questions, on which I
could not find some specific information:

(1) after setting up an entity, a delegator and
I datasource, which seem to work together now,
how (or where?) is the exchange of RECORDS with the
external database? ofbiz does not seem to
automatically detect and show the records from the
mysql-database.
Maybe my entity definitions are still wrong,
but then without error messages.
However: no records are imported or displayed
in the view. So: how can I get them from the mysql-database?

Also unexpected to me: when I create new records in ofbiz,
they are displayed in ofbiz after creation (as one would
expect for any regular entity) but they are not transferred to
to the external mysql-database (which I guess could be
the purpose of a entity with associated externally
referenced datasource).

So it seems that ofbiz did recognize the structure of
the external mysql-database, but then ignores to
exchange the data between ofbiz and the database.

So how does ofbiz exchange records between
ofbiz and the external database (in a synchronized way)?

Is there further setup or custom implmentation necessary?

(2) the setup of a datasource is placed in entityengine.xml
in the framework/entity/config folder.
Is there a way to extend it with entries
defined in hot-deploy/.../entitydef/config/entityengine.xml ?

I tried to setup another entityengine.xml there,
but this approach seemed to be ignored by ofbiz.


Thank you!