Guys, How do I register I_xx
classes in metasfresh after creating a new package?
I generated interfaces and X classes from model generator but I can’t seem to grasp how we can connect those classes in metasfresh.
What I actually wanted to know is what is development workflow for metasfresh. Because it might sound vague so
i am asking questions in small pieces.
Idempiere has factories to register models, callouts, processes and other things. How are such things accomplished in metasfresh ?
My thoughts and learning process;
learning-metasfresh
Hi @dipeshdulal
basically, those generated classes just need to be in the classpath
Maybe as a (fairly random and probably not the best) example you can check out
/de.metas.shipper.gateway.dhl
- it’s declared as a modules in the metasfresh repo’s parent pom.xml
- it’s declared as a dependency somewhere (didn’t check)
- it has sql migration files in
/de.metas.shipper.gateway.dhl/src/main/sql/postgresql/system/99-de.metas.shipper.gateway.dhl
- (those are also separately declared in
/metasfresh-dist/dist/pom.xml
) to make sure thaey are automatically applied on a rollout)
- processes generally still need to be registered via
AD_Process
table
- (note: we use model validator and model interceptor synonymous, but we prefer the term model interceptor)
- here is an example for a model interceptor that is also annotated as
@Component
and therefore automatically configured: /de.metas.contracts/src/main/java/de/metas/contracts/commission/commissioninstance/interceptor/C_Invoice_Candidate.java
- here is an example that for a class that is both and interceptor and a callout:
/de.metas.contracts/src/main/java/de/metas/contracts/commission/salesrep/interceptor/C_Invoice.java
I skipped over the document you shared. Great work!
From the documentation and codes it looks like the the system uses Camel and
ApacheCXF for services architecture.
To clarify: AFAIU we use ApacheCXF only for rest-via activemq (yeah, don’t ask) and are going to phase it out alltogether at one point.
To communicate between components we use rabbitmq (btw, check out de.metas.event
).
Camel we use in some cases to communicate with 3rd-party system, mostly for EDI purposes.
Basically, after updating pom.xml dependencies I was able to get custom model working.
I updated
metasfresh-webui-api/pom.xml
metasfresh/pom.xml
de.metas.fresh.base/pom.xml
So, I need to update dependencies for these three files right ? Or, Can I get away with just updating two files metasfresh/pom.xml
to decleare modules and de.metas.fresh.base/pom.xml
to give base project a tip that this project exists as a dependency.
Thanks so much, @metas-ts your words really helped me a lot. But I can’t seem to get @Callout
and @CalloutMethod
to work. @Intercept
works on the same classs but applying @Callout
doesn’t do the trick 
So, after checking out de.metas.event
de.metas.ui.web.notification/UserNotificationsService
is actually responsible for receiving notifications to the client via websocket after receiving from de.metas.event
located in main server right ?
Update
#1:
I was able to make callouts
and model interceptors
work by using AbstractModuleInterceptor
and AbstractModelInterceptor
. Basically, I manually registered Model Interceptors and Callouts instead of depending upon spring do its magic (don’t know why it doesn’t work automatically just with @Component
annotation)
I created Model Interceptor Register by doing;
@Component
public class PhoenixModelIntercept extends AbstractModelInterceptor{
@Override
protected void onInit(IModelValidationEngine engine, I_AD_Client client) {
engine.addModelValidator(new PHN_INFO(), client);
engine.addModelValidator(new PHN_ADDR(), client);
}
}
Similarly. I created Callout Register Class by doing;
@Component
public class Main extends AbstractModuleInterceptor{
@Override
protected void registerCallouts(IProgramaticCalloutProvider calloutsRegistry) {
calloutsRegistry.registerAnnotatedCallout(new PHN_INFO());
calloutsRegistry.registerAnnotatedCallout(new PHN_ADDR());
}
}
Here, PHN_INFO
and PHN_ADDR
are two model interceptors as well as callouts for my test table.