Skip to content

Commit

Permalink
KAA-876: merge develop branch + Update new REST API methods to work w…
Browse files Browse the repository at this point in the history
…ith ApplicationToken instead of ApplicationId
  • Loading branch information
ashvayka committed Apr 21, 2016
2 parents f79e38a + b5d6a53 commit 1793426
Show file tree
Hide file tree
Showing 24 changed files with 1,514 additions and 180 deletions.
2 changes: 1 addition & 1 deletion client/client-multi/client-objective-c/mainpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h3>Building Kaa Objective-C SDK</h3>
<code>$ ./build.sh compile</code>

<h3>Link Kaa library to your project</h3>
<p>Drag and drop Kaa XCode project workspace as sub-module to your project and add libKaa.a binary to "Link Binary with Libraries" in Build Phases tab. In Build Settings tab find property called "Other Linker Flags" and set it's value to -ObjC. In Build Settings tab find property called "User Header Search Paths" and set it's value to "$(BUILT_PRODUCTS_DIR)" and switch value in right column to recursive.
<p>Drag and drop Kaa XCode project workspace as sub-module to your project and add Kaa.framework binary to "Link Binary with Libraries" in Build Phases tab. Add new "Copy Files" phase, set its destination to "Frameworks" and add Kaa.framework there. In Build Settings tab find property called "Other Linker Flags" and set it's value to -ObjC. In Build Settings tab find property called "Header Search Paths" and set it's value to "$(BUILT_PRODUCTS_DIR)" and switch value in right column to recursive. In Build Settings tab find property "Allow Non-modular Includes In Framework Modules" and set its value to "Yes".
</p>

<h2>Programming guide</h2>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
* @return the list of CTL schemas available in the database.
*/
List<T> findSystemSchemas();

/**
* Find available for tenant(include system scope) CTL schemas by given tenant identifier.
*
* @param tenantId the tenant identifier.
* @return the list of available schemas.
*/
List<T> findAvailableSchemasForTenant(String tenantId);

/**
* Find available for application(include system and tenant scope) CTL schemas by given tenant and application identifier.
*
Expand All @@ -56,9 +56,9 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
* @param version the schema version.
* @return the CTL schema with the given meta info id and version.
*/

T findByMetaInfoIdAndVer(String metaInfoId, Integer version);

/**
* Find CTL schema with the given fully qualified name, version, tenant and application identifiers.
*
Expand Down Expand Up @@ -91,7 +91,7 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
* @return the latest version of CTL schema with the given fully qualified name, tenant and application identifiers.
*/
T findLatestByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId);

/**
* Find the last version of CTL schema with the given meta info id.
*
Expand All @@ -100,7 +100,7 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
*/

T findLatestByMetaInfoId(String metaInfoId);

/**
* Find all available versions of CTL schema with the given fully qualified name, tenant and application identifiers.
*
Expand All @@ -110,7 +110,7 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
* @return the list of available versions of CTL schema with the given fully qualified name, tenant and application identifiers.
*/
List<T> findAllByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId);

/**
* Find all available versions of CTL schema with the given meta info id.
*
Expand All @@ -126,5 +126,5 @@ public interface CTLSchemaDao<T> extends SqlDao<T> {
* @return the list of dependents schemas from schema with given identifier.
*/
List<T> findDependentSchemas(String schemaId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class HibernateCTLSchemaDao extends HibernateAbstractDao<CTLSchema> imple
protected Class<CTLSchema> getEntityClass() {
return CTLSchema.class;
}

private Criterion buildScopeCriterion(String tenantId, String applicationId) {
if (isBlank(tenantId)) {
// SYSTEM - tenantId=null && appId=null
Expand Down Expand Up @@ -106,7 +106,7 @@ public List<CTLSchema> findSystemSchemas() {
}
return schemas;
}

@Override
public List<CTLSchema> findAvailableSchemasForTenant(String tenantId) {
LOG.debug("Searching available ctl schemas for tenant with id [{}]", tenantId);
Expand Down Expand Up @@ -134,7 +134,7 @@ public List<CTLSchema> findAvailableSchemasForApplication(String tenantId, Strin
}
return availableSchemas;
}

@Override
public CTLSchema findByFqnAndVerAndTenantIdAndApplicationId(String fqn,
Integer version, String tenantId, String applicationId) {
Expand All @@ -160,7 +160,7 @@ public CTLSchema findByFqnAndVerAndTenantIdAndApplicationId(String fqn,
}
return ctlSchema;
}

@Override
public CTLSchema findByMetaInfoIdAndVer(String metaInfoId, Integer version) {
CTLSchema ctlSchema = null;
Expand All @@ -179,7 +179,7 @@ public CTLSchema findByMetaInfoIdAndVer(String metaInfoId, Integer version) {
}
return ctlSchema;
}

@Override
public CTLSchema findAnyByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integer version, String tenantId,
String applicationId) {
Expand All @@ -200,7 +200,7 @@ public CTLSchema findAnyByFqnAndVerAndTenantIdAndApplicationId(String fqn, Integ
}
return ctlSchema;
}

@Override
public CTLSchema findLatestByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId) {
LOG.debug("Searching latest ctl schema by fqn [{}], tenantId [{}] and applicationId [{}]", fqn, tenantId, applicationId);
Expand All @@ -223,7 +223,7 @@ public CTLSchema findLatestByFqnAndTenantIdAndApplicationId(String fqn, String t
}
return latestSchema;
}

@Override
public CTLSchema findLatestByMetaInfoId(String metaInfoId) {
CTLSchema latestSchema = null;
Expand All @@ -243,7 +243,7 @@ public CTLSchema findLatestByMetaInfoId(String metaInfoId) {
}
return latestSchema;
}

@Override
public List<CTLSchema> findAllByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId) {
LOG.debug("Searching available version of ctl schema by fqn [{}], tenantId [{}] and applicationId [{}]", fqn, tenantId, applicationId);
Expand All @@ -265,7 +265,7 @@ public List<CTLSchema> findAllByFqnAndTenantIdAndApplicationId(String fqn, Strin
}
return schemas;
}

@Override
public List<CTLSchema> findAllByMetaInfoId(String metaInfoId) {
LOG.debug("Searching available version of ctl schema by meta info id [{}]", metaInfoId);
Expand All @@ -280,7 +280,7 @@ public List<CTLSchema> findAllByMetaInfoId(String metaInfoId) {
}
return schemas;
}

@Override
public List<CTLSchema> findDependentSchemas(String schemaId) {
LOG.debug("Searching dependents ctl schemas for schema with id [{}]", schemaId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
public class CTLSchemaMetaInfo extends GenericModel<CTLSchemaMetaInfoDto> implements Serializable {

private static final long serialVersionUID = 3185049875063895954L;

@Column(name = CTL_SCHEMA_META_INFO_FQN)
private String fqn;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(nullable = true, name = CTL_SCHEMA_META_INFO_TENANT_ID, foreignKey = @ForeignKey(name = CTL_SCHEMA_META_INFO_TENANT_FK))
private Tenant tenant;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(nullable = true, name = CTL_SCHEMA_META_INFO_APPLICATION_ID, foreignKey = @ForeignKey(name = CTL_SCHEMA_META_INFO_APPLICATION_FK))
private Application application;
private Application application;

public CTLSchemaMetaInfo() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public CTLSchemaDto updateCTLSchema(CTLSchemaDto ctlSchema) {
throw new DatabaseProcessingException("Can't find common type version by id.");
}
}

@Override
public CTLSchemaMetaInfoDto updateCTLSchemaMetaInfoScope(CTLSchemaMetaInfoDto ctlSchemaMetaInfo) {
validateObject(ctlSchemaMetaInfo, "Incorrect ctl schema meta info object");
Expand All @@ -245,7 +245,7 @@ public CTLSchemaMetaInfoDto updateCTLSchemaMetaInfoScope(CTLSchemaMetaInfoDto ct
throw new DatabaseProcessingException("Can't find common type by id.");
}
}

@Override
public List<CTLSchemaMetaInfoDto> findSiblingsByFqnTenantIdAndApplicationId(String fqn, String tenantId, String applicationId) {
if (isBlank(fqn)) {
Expand All @@ -254,7 +254,7 @@ public List<CTLSchemaMetaInfoDto> findSiblingsByFqnTenantIdAndApplicationId(Stri
LOG.debug("Find sibling ctl schemas by fqn {}, tenant id {} and application id {}", fqn, tenantId, applicationId);
return convertDtoList(ctlSchemaMetaInfoDao.findSiblingsByFqnTenantIdAndApplicationId(fqn, tenantId, applicationId));
}

private boolean checkScopeUpdate(CTLSchemaMetaInfoDto newSchemaMetaInfo, CTLSchemaMetaInfoDto prevSchemaMetaInfo) {
if (!newSchemaMetaInfo.equals(prevSchemaMetaInfo)) {
if (isBlank(newSchemaMetaInfo.getFqn())) {
Expand Down Expand Up @@ -330,7 +330,7 @@ public CTLSchemaDto findCTLSchemaByFqnAndVerAndTenantIdAndApplicationId(String f
LOG.debug("Find ctl schema by fqn {} version {}, tenant id {} and application id {}", fqn, version, tenantId, applicationId);
return DaoUtil.getDto(ctlSchemaDao.findByFqnAndVerAndTenantIdAndApplicationId(fqn, version, tenantId, applicationId));
}

@Override
public CTLSchemaDto findByMetaInfoIdAndVer(String metaInfoId, Integer version) {
if (isBlank(metaInfoId) || version == null) {
Expand All @@ -349,7 +349,7 @@ public CTLSchemaDto findAnyCTLSchemaByFqnAndVerAndTenantIdAndApplicationId(Strin
LOG.debug("Find any ctl schema by fqn {} version {}, tenant id {} and application id {}", fqn, version, tenantId, applicationId);
return DaoUtil.getDto(ctlSchemaDao.findAnyByFqnAndVerAndTenantIdAndApplicationId(fqn, version, tenantId, applicationId));
}

@Override
public List<CTLSchemaDto> findSystemCTLSchemas() {
LOG.debug("Find system ctl schemas");
Expand All @@ -367,7 +367,7 @@ public List<CTLSchemaMetaInfoDto> findAvailableCTLSchemasMetaInfoForTenant(Strin
LOG.debug("Find system and tenant scopes ctl schemas by tenant id {}", tenantId);
return getMetaInfoFromCTLSchema(ctlSchemaDao.findAvailableSchemasForTenant(tenantId));
}

@Override
public List<CTLSchemaMetaInfoDto> findAvailableCTLSchemasMetaInfoForApplication(String tenantId, String applicationId) {
LOG.debug("Find system, tenant and application scopes ctl schemas by application id {}", applicationId);
Expand All @@ -380,14 +380,14 @@ public CTLSchemaDto findLatestCTLSchemaByFqnAndTenantIdAndApplicationId(String f
LOG.debug("Find latest ctl schema by fqn {}, tenantId {} and applicationId {}", fqn, tenantId, applicationId);
return DaoUtil.getDto(ctlSchemaDao.findLatestByFqnAndTenantIdAndApplicationId(fqn, tenantId, applicationId));
}

@Override
public CTLSchemaDto findLatestByMetaInfoId(String metaInfoId) {
validateString(metaInfoId, "Incorrect meta info id for ctl schema request.");
LOG.debug("Find latest ctl schema by meta info id {}", metaInfoId);
return DaoUtil.getDto(ctlSchemaDao.findLatestByMetaInfoId(metaInfoId));
}

@Override
public List<CTLSchemaDto> findAllCTLSchemasByFqnAndTenantIdAndApplicationId(String fqn, String tenantId, String applicationId) {
validateString(fqn, "Incorrect fqn for ctl schema request.");
Expand Down Expand Up @@ -460,7 +460,7 @@ private List<CTLSchemaMetaInfoDto> getMetaInfoFromCTLSchema(List<CTLSchema> sche
List<CTLSchemaMetaInfoDto> result = new ArrayList<>(metaInfoMap.values());
return result;
}

@Override
public FileData shallowExport(CTLSchemaDto schema) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public TopicDto findTopicById(String id) {

@Override
public List<TopicDto> findTopicsByAppId(String appId) {
validateId(appId, "Can't find topic. Invalid topic id " + appId);
validateId(appId, "Can't find topic. Invalid application id " + appId);
return convertDtoList(topicDao.findTopicsByAppId(appId));
}

Expand Down
33 changes: 0 additions & 33 deletions server/common/dao/src/main/resources/sql-dao.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class HibernateCTLSchemaDaoTest extends HibernateAbstractTest {
private CTLSchemaDto systemSchema;

private static final String SYSTEM_FQN = "org.kaaproject.kaa.ctl.SystemSchema";

@Before
public void before() {
clearDBData();
Expand Down Expand Up @@ -95,7 +95,7 @@ public void saveCTLSchemaWithSameFqnAndVersion() {
ctlSchemaDao.save(generateCTLSchema(DEFAULT_FQN, new Tenant(tenant), 11, null));
ctlSchemaDao.save(generateCTLSchema(DEFAULT_FQN, null, 11, null));
}

private CTLSchema generateCTLSchema(String fqn, Tenant tenant, int version, String body) {
CTLSchema ctlSchema = new CTLSchema();
if (tenant == null) {
Expand Down Expand Up @@ -125,7 +125,6 @@ public void saveCTLSchemaWithDependency() throws InterruptedException {
Assert.assertEquals(expected.size(), dep.size());
}


@Test
public void testFindByFqnAndVerAndTenantIdAndApplicationId() {
CTLSchema found = ctlSchemaDao.findByFqnAndVerAndTenantIdAndApplicationId(firstSchema.getMetaInfo().getFqn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,10 @@ public void findLogSchemaByIdTest() {

Assert.assertNotNull(dto);
}

@Test
public void findLogSchemaVersionsByApplicationIdTest() {
List<VersionDto> schemas = logSchemaService.findLogSchemaVersionsByApplicationId(applicationDto.getId());

Assert.assertEquals(1, schemas.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,41 @@ public void beforeTest() throws Exception {
}

@Test
public void findUserVerifiersByAppIdTest(){
UserVerifierDto verifierDto1 = generateUserVerifierDto(null, null);
List<UserVerifierDto> found = verifierService.findUserVerifiersByAppId(verifierDto1.getApplicationId());
public void findUserVerifiersByAppIdTest() {
UserVerifierDto verifierDto = generateUserVerifierDto(null, null);
List<UserVerifierDto> found = verifierService.findUserVerifiersByAppId(verifierDto.getApplicationId());
Assert.assertEquals(2, found.size());
}

@Test
public void findUserVerifiersByAppIdAndVerifierTokenTest(){
public void findUserVerifiersByAppIdAndVerifierTokenTest() {
UserVerifierDto verifierDto = generateUserVerifierDto(null, null);
UserVerifierDto found = verifierService.findUserVerifiersByAppIdAndVerifierToken(verifierDto.getApplicationId(), verifierDto.getVerifierToken());
Assert.assertEquals(verifierDto, found);
}

@Test
public void findUserVerifierByIdTest(){
public void findUserVerifierByIdTest() {
UserVerifierDto verifierDto = generateUserVerifierDto(null, null);
UserVerifierDto found = verifierService.findUserVerifierById(verifierDto.getId());
Assert.assertEquals(verifierDto, found);
}

@Test
public void saveUserVerifierTest(){
public void saveUserVerifierTest() {
UserVerifierDto verifierDto = generateUserVerifierDto(null, null);
UserVerifierDto found = verifierService.saveUserVerifier(verifierDto);
Assert.assertEquals(verifierDto, found);
}

@Test
public void saveUserVerifierNullVerifierDtoTest(){
public void saveUserVerifierNullVerifierDtoTest() {
UserVerifierDto found = verifierService.saveUserVerifier(null);
Assert.assertNull(found);
}

@Test
public void removeUserVerifierByIdTest(){
public void removeUserVerifierByIdTest() {
UserVerifierDto verifierDto = generateUserVerifierDto(null, null);
verifierService.removeUserVerifierById(verifierDto.getId());
UserVerifierDto found = verifierService.findUserVerifierById(verifierDto.getId());
Expand Down

0 comments on commit 1793426

Please sign in to comment.