Skip to content

Commit

Permalink
KAA-603: CTL feature implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikulikov committed Feb 18, 2016
1 parent a937ab4 commit 5ecf6d6
Show file tree
Hide file tree
Showing 138 changed files with 4,171 additions and 2,406 deletions.
Expand Up @@ -4,5 +4,7 @@
"namespace": "org.kaaproject.kaa.schema.system",
"version": 1,
"dependencies": [],
"displayName": "Empty Data",
"description": "Auto generated",
"fields": []
}
Expand Up @@ -62,9 +62,8 @@
import org.kaaproject.kaa.common.dto.admin.SdkProfileDto;
import org.kaaproject.kaa.common.dto.admin.TenantUserDto;
import org.kaaproject.kaa.common.dto.admin.UserDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaInfoDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaScopeDto;
import org.kaaproject.kaa.common.dto.event.AefMapInfoDto;
import org.kaaproject.kaa.common.dto.event.ApplicationEventFamilyMapDto;
import org.kaaproject.kaa.common.dto.event.EcfInfoDto;
Expand Down Expand Up @@ -953,49 +952,77 @@ public String getFilename() {
return bar;
}

public CTLSchemaInfoDto saveCTLSchema(String body, CTLSchemaScopeDto scope, String applicationId) {
public CTLSchemaDto saveCTLSchema(String body, String tenantId, String applicationId) {
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("body", body);
if (scope != null) {
params.add("scope", scope.name());
if (tenantId != null) {
params.add("tenantId", tenantId);
}
if (applicationId != null) {
params.add("applicationId", applicationId);
}
return restTemplate.postForObject(url + "CTL/saveSchema", params, CTLSchemaInfoDto.class);
return restTemplate.postForObject(url + "CTL/saveSchema", params, CTLSchemaDto.class);
}

public void deleteCTLSchemaByFqnAndVersion(String fqn, Integer version) {
public void deleteCTLSchemaByFqnVersionTenantIdAndApplicationId(String fqn,
Integer version,
String tenantId,
String applicationId) {
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
params.add("fqn", fqn);
params.add("version", version);
if (tenantId != null) {
params.add("tenantId", tenantId);
}
if (applicationId != null) {
params.add("applicationId", applicationId);
}
restTemplate.postForLocation(url + "CTL/deleteSchema", params);
}

public CTLSchemaInfoDto getCTLSchemaByFqnAndVersion(String fqn, Integer version) {
return restTemplate.getForObject(url + "CTL/getSchema?fqn={fqn}&version={version}", CTLSchemaInfoDto.class, fqn, version);
public CTLSchemaDto getCTLSchemaByFqnVersionTenantIdAndApplicationId(String fqn, Integer version, String tenantId, String applicationId) {
if (tenantId != null && applicationId != null) {
return restTemplate.getForObject(url + "CTL/getSchema?fqn={fqn}&version={version}&tenantId={tenantId}&applicationId={applicationId}", CTLSchemaDto.class, fqn, version, tenantId, applicationId);
}else if (tenantId != null) {
return restTemplate.getForObject(url + "CTL/getSchema?fqn={fqn}&version={version}&tenantId={tenantId}", CTLSchemaDto.class, fqn, version, tenantId);
} else {
return restTemplate.getForObject(url + "CTL/getSchema?fqn={fqn}&version={version}", CTLSchemaDto.class, fqn, version);
}
}

public boolean checkFqnExists(String fqn, String tenantId, String applicationId) {
if (tenantId != null && applicationId != null) {
return restTemplate.getForObject(url + "CTL/checkFqn?fqn={fqn}&tenantId={tenantId}&applicationId={applicationId}",
Boolean.class, fqn, tenantId, applicationId);
} else if (tenantId != null) {
return restTemplate.getForObject(url + "CTL/checkFqn?fqn={fqn}&tenantId={tenantId}", Boolean.class, fqn, tenantId);
} else {
return restTemplate.getForObject(url + "CTL/checkFqn?fqn={fqn}", Boolean.class, fqn);
}
}

public CTLSchemaMetaInfoDto updateCTLSchemaMetaInfoScope(CTLSchemaMetaInfoDto ctlSchemaMetaInfo) {
return restTemplate.postForObject(url + "CTL/updateScope", ctlSchemaMetaInfo, CTLSchemaMetaInfoDto.class);
}

public List<CTLSchemaMetaInfoDto> getCTLSchemasAvailable() {
public List<CTLSchemaMetaInfoDto> getSystemLevelCTLSchemas() {
ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>> typeRef = new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {
};
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getSchemas", HttpMethod.GET, null, typeRef);
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getSystemSchemas", HttpMethod.GET, null, typeRef);
return entity.getBody();
}

public List<CTLSchemaMetaInfoDto> getCTLSchemasByScope(String scopeName) {
public List<CTLSchemaMetaInfoDto> getTenantLevelCTLSchemas() {
ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>> typeRef = new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {
};
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getSchemas?scope=" + scopeName,
HttpMethod.GET, null, typeRef);
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getTenantSchemas", HttpMethod.GET, null, typeRef);
return entity.getBody();
}

public List<CTLSchemaMetaInfoDto> getCTLSchemasByApplicationId(String applicationId) {
public List<CTLSchemaMetaInfoDto> getApplicationLevelCTLSchemas(String applicationId) {
ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>> typeRef = new ParameterizedTypeReference<List<CTLSchemaMetaInfoDto>>() {
};
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getSchemas?applicationId=" + applicationId,
HttpMethod.GET, null, typeRef);
ResponseEntity<List<CTLSchemaMetaInfoDto>> entity = restTemplate.exchange(url + "CTL/getApplicationSchemas/" + applicationId, HttpMethod.GET, null, typeRef);
return entity.getBody();
}

Expand Down
Expand Up @@ -16,13 +16,13 @@

package org.kaaproject.kaa.server.common.dao;

import java.util.List;

import org.apache.avro.Schema;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaDto;
import org.kaaproject.kaa.common.dto.ctl.CTLSchemaMetaInfoDto;
import org.kaaproject.kaa.common.dto.file.FileData;

import java.util.List;

/**
* Common type library service.
*/
Expand All @@ -48,9 +48,29 @@ public interface CTLService {
* @return CTLSchemaDto the updated object.
*/
CTLSchemaDto updateCTLSchema(CTLSchemaDto ctlSchema);

/**
* Update existing CTL schema meta info scope by the given CTL schema meta info object.
*
* @param ctlSchemaMetaInfo
* the CTL schema meta info object.
* @return CTLSchemaMetaInfoDto the updated CTL schema meta info object.
*/
CTLSchemaMetaInfoDto updateCTLSchemaMetaInfoScope(CTLSchemaMetaInfoDto ctlSchemaMetaInfo);

/**
* Remove a CTL schema of the given tenant with the given fully qualified
* Find CTL schema meta infos which are the application level siblings to the CTL
* of the given fully qualified name, tenant and application identifiers.
*
* @param fqn the fully qualified.
* @param tenantId the tenant identifier.
* @param applicationId the application identifier.
* @return the CTL schema meta information objects which are the siblings to the given CTL.
*/
List<CTLSchemaMetaInfoDto> findSiblingsByFqnTenantIdAndApplicationId(String fqn, String tenantId, String applicationId);

/**
* Remove a CTL schema of the given tenant or application with the given fully qualified
* name and version number.
*
* @param fqn
Expand All @@ -59,8 +79,10 @@ public interface CTLService {
* the schema version.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
*/
void removeCTLSchemaByFqnAndVerAndTenantId(String fqn, Integer version, String tenantId);
void removeCTLSchemaByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integer version, String tenantId, String applicationId);

/**
* Find a CTL schema with the given identifier.
Expand All @@ -81,15 +103,16 @@ public interface CTLService {
CTLSchemaDto saveCTLSchema(CTLSchemaDto ctlSchemaDto);

/**
* Remove a CTL schema with the given identifier.
* Find CTL schema with the given meta info id and version.
*
* @param schemaId
* the CTL schema identifier.
*/
void removeCTLSchemaById(String schemaId);

* @param metaInfoId the id of meta info object.
* @param version the schema version.
* @return the CTL schema with the given meta info id and version.
*/
CTLSchemaDto findByMetaInfoIdAndVer(String metaInfoId, Integer version);

/**
* Find a CTL schema of the given tenant with the given fully qualified name
* Find a CTL schema of the given tenant or application with the given fully qualified name
* and version number.
*
* @param fqn
Expand All @@ -98,75 +121,111 @@ public interface CTLService {
* the CTL schema version.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
* @return the CTL schema with the given fully qualified name and version
* number.
*/
CTLSchemaDto findCTLSchemaByFqnAndVerAndTenantId(String fqn, Integer version, String tenantId);
CTLSchemaDto findCTLSchemaByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integer version, String tenantId, String applicationId);

/**
* Find any CTL schema of the given tenant or application with the given fully qualified name
* and version number.
*
* @param fqn
* the fully qualified name.
* @param version
* the CTL schema version.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
* @return the any CTL schema with the given fully qualified name and version
* number.
*/
CTLSchemaDto findAnyCTLSchemaByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integer version, String tenantId, String applicationId);

/**
* Find system CTL schemas available in the database.
*
* @return the list of available system CTL schemas in the database.
*/
List<CTLSchemaDto> findSystemCTLSchemas();

/**
* Find system meta information of CTL schemas available in the database.
* Find system CTL schemas meta info available in the database.
*
* @return the list of available system CTL meta information in the
* database.
* @return the list of available system CTL schemas meta info in the database.
*/
List<CTLSchemaMetaInfoDto> findSystemCTLSchemasMetaInfo();

/**
* Find the last version of CTL schema with the given fully qualified name.
* Find available CTL schemas meta info for tenant(include
* system scope) with the given tenant identifier.
*
* @param fqn
* the fully qualified name.
* @return the latest version of CTL schema with the given fully qualified
* name.
* @param tenantId
* the tenant identifier.
* @return the list of available CTL schemas meta info for tenant
* with given identifier.
*/
CTLSchemaDto findLatestCTLSchemaByFqn(String fqn);

List<CTLSchemaMetaInfoDto> findAvailableCTLSchemasMetaInfoForTenant(String tenantId);
/**
* Find CTL schemas available in the database.
* Find available CTL schemas meta info for application(include
* system and tenant scope) with the given tenant and application identifier.
*
* @return the list of available CTL schemas in the database.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
* @return the list of available CTL schemas meta info for application
* with given identifier.
*/
List<CTLSchemaDto> findCTLSchemas();
List<CTLSchemaMetaInfoDto> findAvailableCTLSchemasMetaInfoForApplication(String tenantId, String applicationId);

/**
* Find meta information of CTL schemas with the given application
* identifier.
* Find the last version of CTL schema with the given fully qualified name, tenant and application identifier.
*
* @param appId
* @param fqn
* the fully qualified name.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
* @return the list of meta information of CTL schemas with application
* identifier.
* @return the latest version of CTL schema with the given fully qualified
* name, tenant and application identifier.
*/
List<CTLSchemaMetaInfoDto> findCTLSchemasMetaInfoByApplicationId(String appId);
CTLSchemaDto findLatestCTLSchemaByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId);

/**
* Find meta information of CTL schemas with the given tenant identifier with tenant scope.
* Find the last version of CTL schema with the given meta info id.
*
* @param tenantId
* the tenant identifier.
* @return the list of meta information of CTL schemas with tenant
* identifier.
*/
List<CTLSchemaMetaInfoDto> findTenantCTLSchemasMetaInfoByTenantId(String tenantId);
* @param metaInfoId the id of meta info object.
* @return the latest version of CTL schema with the given meta info id.
*/
CTLSchemaDto findLatestByMetaInfoId(String metaInfoId);

/**
* Find available CTL schemas meta information schemas for tenant(include
* system scope) with the given tenant identifier.
* Find all available versions of CTL schema with the given fully qualified name, tenant and application identifier.
*
* @param fqn
* the fully qualified name.
* @param tenantId
* the tenant identifier.
* @return the list of available meta information of CTL schemas for tenant
* with given identifier.
* @param applicationId
* the application identifier.
* @return the list of available versions of CTL schema with the given fully qualified
* name, tenant and application identifier.
*/
List<CTLSchemaMetaInfoDto> findAvailableCTLSchemasMetaInfo(String tenantId);

List<CTLSchemaDto> findAllCTLSchemasByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId);

/**
* Find CTL schemas available in the database.
*
* @return the list of available CTL schemas in the database.
*/
List<CTLSchemaDto> findCTLSchemas();

/**
* Find the dependents CTL schemas from CTL schema with the given schema
* identifier
Expand All @@ -179,19 +238,21 @@ public interface CTLService {
List<CTLSchemaDto> findCTLSchemaDependents(String schemaId);

/**
* Find the dependents CTL schemas from CTL schema with the given tenant,
* given fully qualified name and version number.
* Find the dependents CTL schemas from CTL schema with the given tenant, application,
* fully qualified name and version number.
*
* @param fqn
* the fully qualified name.
* @param version
* the schema version.
* @param tenantId
* the tenant identifier.
* @param applicationId
* the application identifier.
* @return the list of dependents CTL schemas from CTL schema with the given
* tenant identifier, fully qualified name and version.
* tenant, application, fully qualified name and version.
*/
List<CTLSchemaDto> findCTLSchemaDependents(String fqn, Integer version, String tenantId);
List<CTLSchemaDto> findCTLSchemaDependents(String fqn, Integer version, String tenantId, String applicationId);

/**
* Exports the body of a CTL schema.
Expand Down

0 comments on commit 5ecf6d6

Please sign in to comment.