mattkol / sugaronrest Goto Github PK
View Code? Open in Web Editor NEWSugarOnRest is a Java SugarCRM/SuiteCRM Rest API Client. It is Java Wrapper for the SugarCRM/SuiteCRM REST API Client.
License: MIT License
SugarOnRest is a Java SugarCRM/SuiteCRM Rest API Client. It is Java Wrapper for the SugarCRM/SuiteCRM REST API Client.
License: MIT License
I am trying to create a new opportunity and associate the opportunity to an existing account, but I am not able to see the way to do it. For example I am trying with this test method where I use my own Configuration object where I store the credentials to access SugarCRM
public static void createTestAssociation(Configuration configuration) throws Exception {
String sugarcrmHost = configuration.getSugarcrmHost();
String urlpath = getUrlPath(sugarcrmHost);
String username = configuration.getSugarcrmUsername();
String password = configuration.getSugarcrmPassword();
SugarRestClient client = new SugarRestClient(urlpath, username, password);
String accountId = "5c68e9c7-d66e-a679-9da4-577e5cca64c3";
String opportunityId = "ca9ebdea-85d5-7fca-e078-58ee55950447";
AccountsOpportunities insertAccOpp = new AccountsOpportunities();
insertAccOpp.setAccountId(accountId);
insertAccOpp.setOpportunityId(opportunityId);
SugarRestRequest request = new SugarRestRequest("AccountsOpportunities", RequestType.Create);
request.setParameter(insertAccOpp);
//request.setModuleType(AccountsOpportunities.class);
// Select fields.
List<String> selectFields = new ArrayList<String>();
selectFields.add(NameOf.AccountsOpportunities.AccountId);
selectFields.add(NameOf.AccountsOpportunities.OpportunityId);
request.getOptions().setSelectFields(selectFields);
SugarRestResponse accOppResponse = client.execute(request);
String insertId = (accOppResponse.getData() == null) ? StringUtils.EMPTY : accOppResponse.getData().toString();
}
Could you please tell me what is wrong?
Many thanks.
I've noticed the following (pseudo-)code does not work, it's related to sending a LinkedBulkRead request with a custom class for the linked information (I've added a rather short incremental id for the Accounts entries):
SugarRestRequest request = new SugarRestRequest(
RequestType.LinkedBulkRead);
Map<Object, List<String>> linkedListInfo = new HashMap<Object, List<String>>();
List<String> selectAccountFields = new ArrayList<String>();
selectAccountFields.add("id_incr");
linkedListInfo.put(CustomAccount.class, selectAccountFields);
request.setModuleName("Contacts");
request.getOptions().setLinkedModules(linkedListInfo);
SugarRestResponse response = client.execute(request);
The CustomAccount class is a class with the following declaration (first line :):
public class CustomAccount extends Accounts {
and it includes a id_incr field.
Now, the (a bit) confusing thing was that instead of
linkedListInfo.put(CustomAccount.class, selectAccountFields);
I had to use
linkedListInfo.put(Accounts.class, selectAccountFields);
in the request. So I had to use the super class of CustomAccount and then it seemed to work fine. Eventually this problem is due to the code at
, it tried to find the class "com.sugaronrest.modules.CustomAccount" which of course does not exist. I'm not sure if this can be fixed in an easy way, but I think it would be better when in the linkedModules list also custom classes could be used directly.I've noticed that updating linked fields via RequestType.Update does not work, I guess this has not been implemented (yet)? Basically I've created a custom class which extends the Contacts
class and added a link to the EMailAddresses module/db table:
@JsonProperty("email_addresses")
private List<EmailAddresses> emailLink;
Reading works fine with the LinkedBulkRead/LinkedReadById requestType. But changing the mail addresses does not have any effect on the database. I guess at the moment I would have to manually call Update (set_entry) on the EmailAddresses module and then set relationship to those mail addresses with set_relationship afterwards (not possible with SugarOnRest client, is it?).
First off, great work and project!
The following files did not compile for me when using maven due to different casing of file name and class name. So these files (or classes) should be renamed. As these are generated classes, the necessary changes might need to be done in the generating code. The problems were (old name -> fixed name):
OauthTokens.java -> OAuthTokens.java
Emailman.java -> EmailMan.java
AclActions.java -> ACLActions.java
Eapm.java -> EAPM.java
AclRoles.java -> ACLRoles.java
Sugarfeed.java -> SugarFeed.java
Example error:
[ERROR] /home/rrze/unrz/ev29etyn/git/SugarOnRest/sugaronrest/src/main/java/com/sugaronrest/modules/OauthTokens.java:[32,8] class OAuthTokens is public, should be declared in a file named OAuthTokens.java
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.