Giter Site home page Giter Site logo

mattkol / sugaronrest Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 11.0 10.57 MB

SugarOnRest is a Java SugarCRM/SuiteCRM Rest API Client. It is Java Wrapper for the SugarCRM/SuiteCRM REST API Client.

License: MIT License

Java 99.99% HTML 0.01%
sugarcrm suitecrm java-sugarcrm unirest crm

sugaronrest's People

Contributors

frankst2 avatar mattkol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sugaronrest's Issues

accounts_opportunities relationship

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.

Counterintuitive behaviour when sending LinkedBulkRead request with custom classes?

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

Class moduleClass = Class.forName(PackageName + "." + className, false, classLoader);
, 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.

Updating linked fields via RequestType.Update not directly possible?

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?).

Compile failure due to class name not matching file name

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.