I'm trying to write a method that checks for duplicate addresses. You
pass it a partyId and an Address1 line, and it checks all of that party's postal addresses. If one of the addresses matches (only on the address1 line) it returns that postal address's contactMech. If it finds no match it returns false/null. Here's what I have so far. It won't compile. public static GenericValue findDuplicateAddress(String partyId, String incomingAddressLine, GenericDelegator delegator, DispatchContext dctx) { GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); GenericValue party = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId)); Map addresses = dispatcher.runSync("getPartyContactMechValueMaps", UtilMisc.toMap("partyId", partyId, "contactMechId", "POSTAL_ADDRESS", "showOld", false)); // todo // foreach address in list // compare Address 1 Line // if match // return contact mech of address in list // // return null; } The result is this: [javac] /home/david/erp/opentaps/hot-deploy/CatalogImport/src/org/opentaps/CatalogImport/CatalogImportServices.java:52: cannot find symbol [javac] symbol : method GenericDispatcher(org.ofbiz.service.DispatchContext,org.ofbiz.entity.GenericDelegator) [javac] location: class org.opentaps.CatalogImport.CatalogImportServices [javac] GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); Which is weird, because I do have import org.ofbiz.service.GenericDispatcher; at the top. Any help would be much appreciated. |
By the way, my name is David Shere, from Steele Rubber Products. Not
"news.gmane.org". news.gmane.org wrote: > I'm trying to write a method that checks for duplicate addresses. |
In reply to this post by David Shere
how are you compling this.
if by ant and a build the build.xml must have the dir paths to the libraries needed. if your using eclipse make sure all the libraries are called out in the project properties. but the way am doing something similar for fraud detection. news.gmane.org sent the following on 11/16/2007 12:00 PM: > I'm trying to write a method that checks for duplicate addresses. You > pass it a partyId and an Address1 line, and it checks all of that > party's postal addresses. If one of the addresses matches (only on the > address1 line) it returns that postal address's contactMech. If it > finds no match it returns false/null. > > Here's what I have so far. It won't compile. > > public static GenericValue findDuplicateAddress(String partyId, String > incomingAddressLine, GenericDelegator delegator, DispatchContext dctx) > { > GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); > GenericValue party = delegator.findByPrimaryKey("Party", > UtilMisc.toMap("partyId", partyId)); > Map addresses = dispatcher.runSync("getPartyContactMechValueMaps", > UtilMisc.toMap("partyId", partyId, "contactMechId", "POSTAL_ADDRESS", > "showOld", false)); > // todo > // foreach address in list > // compare Address 1 Line > // if match > // return contact mech of address in list > // > // > return null; > } > > The result is this: > [javac] > /home/david/erp/opentaps/hot-deploy/CatalogImport/src/org/opentaps/CatalogImport/CatalogImportServices.java:52: > cannot find symbol > [javac] symbol : method > GenericDispatcher(org.ofbiz.service.DispatchContext,org.ofbiz.entity.GenericDelegator) > > [javac] location: class > org.opentaps.CatalogImport.CatalogImportServices > [javac] GenericDispatcher dispatcher = > GenericDispatcher(dctx, delegator); > > Which is weird, because I do have > import org.ofbiz.service.GenericDispatcher; > at the top. > > Any help would be much appreciated. > > > > |
Taking a peek at the code this line doesn't look valid: GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); There needs to be a "new" before the class name or a method called in the class in order for the line to be valid. So, yeah, it's trying to treat your class name as a local method name or something. -David On Nov 16, 2007, at 2:10 PM, BJ Freeman wrote: > how are you compling this. > if by ant and a build the build.xml must have the dir paths to the > libraries needed. > if your using eclipse make sure all the libraries are called out in > the > project properties. > > but the way am doing something similar for fraud detection. > > > news.gmane.org sent the following on 11/16/2007 12:00 PM: >> I'm trying to write a method that checks for duplicate addresses. >> You >> pass it a partyId and an Address1 line, and it checks all of that >> party's postal addresses. If one of the addresses matches (only on >> the >> address1 line) it returns that postal address's contactMech. If it >> finds no match it returns false/null. >> >> Here's what I have so far. It won't compile. >> >> public static GenericValue findDuplicateAddress(String partyId, >> String >> incomingAddressLine, GenericDelegator delegator, DispatchContext >> dctx) >> { >> GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); >> GenericValue party = delegator.findByPrimaryKey("Party", >> UtilMisc.toMap("partyId", partyId)); >> Map addresses = dispatcher.runSync("getPartyContactMechValueMaps", >> UtilMisc.toMap("partyId", partyId, "contactMechId", "POSTAL_ADDRESS", >> "showOld", false)); >> // todo >> // foreach address in list >> // compare Address 1 Line >> // if match >> // return contact mech of address in list >> // >> // >> return null; >> } >> >> The result is this: >> [javac] >> /home/david/erp/opentaps/hot-deploy/CatalogImport/src/org/opentaps/ >> CatalogImport/CatalogImportServices.java:52: >> cannot find symbol >> [javac] symbol : method >> GenericDispatcher >> (org.ofbiz.service.DispatchContext,org.ofbiz.entity.GenericDelegator) >> >> [javac] location: class >> org.opentaps.CatalogImport.CatalogImportServices >> [javac] GenericDispatcher dispatcher = >> GenericDispatcher(dctx, delegator); >> >> Which is weird, because I do have >> import org.ofbiz.service.GenericDispatcher; >> at the top. >> >> Any help would be much appreciated. >> >> >> >> smime.p7s (3K) Download Attachment |
That's how I originally wrote it, but I got this:
[javac] /home/david/erp/opentaps/hot-deploy/CatalogImport/src/org/opentaps/CatalogImport/CatalogImportServices.java:52: cannot find symbol [javac] symbol : constructor GenericDispatcher(org.ofbiz.service.DispatchContext,org.ofbiz.entity.GenericDelegator) [javac] location: class org.ofbiz.service.GenericDispatcher [javac] GenericDispatcher dispatcher = new GenericDispatcher(dctx, delegator); which should work because the one of the constructor methods is: GenericDispatcher(DispatchContext ctx, GenericDelegator delegator) David E Jones wrote: > > > Taking a peek at the code this line doesn't look valid: > > GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); > > There needs to be a "new" before the class name or a method called in > the class in order for the line to be valid. |
That constructor definitely doesn't exist (ie one that accepts those two parameters). Where did you get the code? Maybe you have some old code or an old API reference or something? I hate to say it, but this is kind of Java 101 type of stuff. Take a look at the GenericDispatcher to see what your options are. Chances are what you want is once of the getLocalDispatcher methods. -David On Nov 16, 2007, at 2:48 PM, David Shere wrote: > That's how I originally wrote it, but I got this: > > [javac] /home/david/erp/opentaps/hot-deploy/CatalogImport/src/org/ > opentaps/CatalogImport/CatalogImportServices.java:52: cannot find > symbol > [javac] symbol : constructor > GenericDispatcher > (org.ofbiz.service.DispatchContext,org.ofbiz.entity.GenericDelegator) > [javac] location: class org.ofbiz.service.GenericDispatcher > [javac] GenericDispatcher dispatcher = new > GenericDispatcher(dctx, delegator); > > which should work because the one of the constructor methods is: > GenericDispatcher(DispatchContext ctx, GenericDelegator delegator) > > David E Jones wrote: >> Taking a peek at the code this line doesn't look valid: >> GenericDispatcher dispatcher = GenericDispatcher(dctx, delegator); >> There needs to be a "new" before the class name or a method called >> in the class in order for the line to be valid. > smime.p7s (3K) Download Attachment |
Free forum by Nabble | Edit this page |