Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TUBEMQ-355] Add business entity for topic manager #271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions tubemq-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
Expand All @@ -34,6 +34,11 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
Expand All @@ -44,6 +49,16 @@
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -60,10 +75,6 @@
<version>3.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.tubemq.manager;

import org.apache.tubemq.manager.backend.AbstractDaemon;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class TubeMQManager extends AbstractDaemon {
public static void main(String[] args) throws Exception {
TubeMQManager manager = new TubeMQManager();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tubemq.manager.controller;

import java.util.List;
import java.util.Optional;
import org.apache.tubemq.manager.entry.BusinessEntry;
import org.apache.tubemq.manager.repository.BusinessRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/business")
public class BusinessController {

@Autowired
private BusinessRepository businessRepository;

/**
* add new business.
*
* @return - businessResult
* @throws Exception - exception
*/
@PostMapping("/add")
public ResponseEntity<?> addBusiness(@RequestBody BusinessEntry entry) throws Exception {
// businessRepository.saveAndFlush(entry);
return ResponseEntity.ok().build();
}

/**
* update business
*
* @return
* @throws Exception
*/
@PostMapping("/update")
public ResponseEntity<?> updateBusiness(@RequestBody BusinessEntry entry) throws Exception {
return ResponseEntity.ok().build();
}

/**
* Check business status by business name.
*
* @return
* @throws Exception
*/
@GetMapping("/check")
public ResponseEntity<?> checkBusinessByName(
@RequestParam String businessName) throws Exception {
List<BusinessEntry> result = businessRepository.findAllByBusinessName(businessName);
return ResponseEntity.ok().build();
}

/**
* get business by id.
*
* @param id business id
* @return BusinessResult
* @throws Exception
*/
@GetMapping("/get/{id}")
public ResponseEntity<BusinessEntry> getBusinessByID(
@PathVariable Long id) throws Exception {
Optional<BusinessEntry> businessEntry = businessRepository.findById(id);
if (businessEntry.isPresent()) {
return ResponseEntity.ok().build();
} else {
return ResponseEntity.notFound().build();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tubemq.manager.controller;

import lombok.Data;

/**
* rest result for business controller
*/
@Data
public class BusinessResult {
private int state;
private String msg;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,120 @@

package org.apache.tubemq.manager.entry;

import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@Entity
@Table(name = "business")
@Data
@EntityListeners(AuditingEntityListener.class) // support CreationTimestamp annotation
public class BusinessEntry {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@GeneratedValue(strategy=GenerationType.AUTO)
private long businessId;

@Size(min = 3, max = 20)
private String name;
@Size(max = 30)
@NotNull
private String businessName;

public Long getId() {
return id;
}
@Size(max = 64)
private String messageType;

@Size(max = 256)
private String businessCnName;

@Size(max = 256)
private String description;

private String bg;

@Size(max = 240)
@NotNull
private String schemaName;

@Size(max = 32)
@NotNull
private String username;

@Size(max = 64)
@NotNull
private String passwd;

@Size(max = 64)
@NotNull
private String topic;

@Size(max = 10)
private String fieldSplitter;

@Size(max = 256)
private String predefinedFields;

private int isHybridDataSource = 0;

@Size(max = 64)
@NotNull
private String encodingType;

private int isSubSort = 0;

private String topologyName;

private String targetServer;

private String targetServerPort;

private String netTarget;

private int status;

private String category;

private int clusterId;

private String inCharge;

private String sourceServer;

private String baseDir;

@CreationTimestamp
private Date createTime;

private String importType;

private String exampleData;

private String tdwAppgroup;

@Column(name = "SN")
private int sn;

@Size(max = 32)
private String issueMethod;

private BusinessEntry() {

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
public BusinessEntry(String businessName, String schemaName,
String username, String passwd, String topic, String encodingType) {
this.businessName = businessName;
this.schemaName = schemaName;
this.username = username;
this.passwd = passwd;
this.topic = topic;
this.encodingType = encodingType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

package org.apache.tubemq.manager.repository;

import java.util.List;
import org.apache.tubemq.manager.entry.BusinessEntry;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface BusinessRepository extends JpaRepository<BusinessEntry, Long> {
public BusinessEntry findByName(String name);
List<BusinessEntry> findAllByBusinessName(String businessName);
BusinessEntry findByBusinessName(String businessName);
}

Loading