GithubHelp home page GithubHelp logo

centurylinkcloud / clc-adapter-orchestrate Goto Github PK

View Code? Open in Web Editor NEW
0.0 24.0 0.0 185 KB

Java library based on SpringData for accessing and working with Orchestrate.

Home Page: https://www.centurylinkcloud.com

Java 100.00%

clc-adapter-orchestrate's Introduction

wfaas-adapter-orchestrate

Getting Started

The easiest way to get start with a Spring application is to define a collection entity using standard Spring Data annotations.

Entity Class

@Collection("MyCollectionName")
public class MyObject {
    
    @Id
    private String id = UUID.randomUUID().toString();
    private String stringProperty;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
    
    public String getStringProperty() {
        return stringProperty;
    }

    public void setStringProperty(String stringProperty) {
        this.stringProperty = stringProperty;
    }

}

You will notice that the @Collection annotation has been applied in this case. When the collection name differs from the entity type's simple name, this annoatation can be used to specify the collection name.

Repository Interface

After you have created and entity class, simply extend our OrchestrateRepository interface. This provides standard CRUD operations, no additional code is required.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

}

Additional Configuration

The best way to configure you application to detect a repository is our @EnableOrchestrateRepositories annotation. This annotation allows you to define the location of you repository interface classes. The configuration will also make these interfaces available to the application as injectable beans in the application context.

@Configuration
@EnableOrchestrateRepositories("path.to.my.repository.interface")
public class Application {
    
    @Bean
    public OrchestrateTemplate orchestrateTemplate() {
        
        OrchestrateTemplate template = new OrchestrateTemplate();
        template.setApiKey("API-KEY-GOES-HERE");
        
        return template;
    
    }
    
} 

The two configuration elements to pay attention to here are the @EnableOrchestrateRepositories annotation defining the location of our interface, as well as the bean definition method creating the OrchestrationTemplate instance. The template is the source of all Orchestrate client operations. This template has several configuration options related to the Orchestrate API and endpoint configuration.

Repository Injection

Now, simply inject your repository into any bean you would like using the standard @Autowire annotation.

@Autowired
private MyRespository repository;

Dynamic Query Interfaces

Spring Data allows for the dynamic parsing and construction of query methods based on interface methods. What follows are functions that are currently supported by the adapter.

Find By With Query Parameters

You can define a dynamic method to locate a single entity.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	MyObject findByFieldName(String value);

}

You can define a dynamic method to locate a list of entities.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	List<MyObject> findByFieldName(String value);

}

You can define a dynamic method to locate and page through entities.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	Page<MyObject> findByFieldName(String value, Pageable req);

}

You can define a dynamic method to locate a Slice, or chunk of entities.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	Slice<MyObject> findByFieldName(String value, Pageable req);

}

You can define a dynamic method with a slightly more complex parameter combination.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	List<MyObject> findByField1NameAndField2Name(String value1, String value2);
	
	List<MyObject> findByField1NameOrField2Name(String value1, String value2);

}

You can define a dynamic method with complex types using nested parameter syntax.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	List<MyObject> findByObjectField_NestedField(String value);

}

You can define a dynamic method with limiting.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	List<MyObject> findFirst10ByFieldName(String value);

}

You can define a dynamic method with sorting.

public interface MyRespository extends OrchestrateRepository<MyObject, String>{

	List<MyObject> findByFieldNameOrderByFieldNameAsc(String value);
	
	List<MyObject> findByFieldName(String value, Sort sort);

}

clc-adapter-orchestrate's People

Contributors

amolia avatar bmh2git avatar popurisiva avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.