Skip to content

Commit

Permalink
KAA-384: fixed compilation errors appeared after configuration moved …
Browse files Browse the repository at this point in the history
…to new place
  • Loading branch information
Sergii Yemets committed Mar 10, 2015
1 parent 6f12129 commit 5acd2a8
Show file tree
Hide file tree
Showing 14 changed files with 132 additions and 94 deletions.
29 changes: 29 additions & 0 deletions examples/jdatacollectiondemo/resources/projects.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!--
Copyright 2014-2015 CyberVision, Inc.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
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.
-->

<projectsConfig>
<project id="jdatacollection_demo">
<name>Java data collection demo</name>
<description>Application on java platform demonstrating data collection subsystem (IoT)</description>
<platform>JAVA</platform>
<sourceArchive>java/jdatacollection_demo.tar.gz</sourceArchive>
<projectFolder>jdatacollection_demo/JDataCollectionDemo</projectFolder>
<sdkLibDir>jdatacollection_demo/JDataCollectionDemo/lib</sdkLibDir>
<destBinaryFile>jdatacollection_demo/JDataCollectionDemo/build/jar/DataCollectionDemo.jar</destBinaryFile>
</project>
</projectsConfig>
Expand Up @@ -35,6 +35,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
This class demonstrates Kaa log upload system. */
public class DataCollector {

private static final int LOGS_TO_SEND_COUNT = 5;
Expand All @@ -44,10 +47,14 @@ public class DataCollector {

public static void main(String[] args) {
LOGGER.info("Data collection demo started");
//Creating Kaa desktop client instance
KaaClient kaaClient = Kaa.newClient(new DesktopKaaPlatformContext());
//setting custom upload strategy
kaaClient.setLogUploadStrategy(new OneLogUploadStrategy());
//starting Kaa client
kaaClient.start();

//sending logs in loop
for (LogData log : getLogs(LOGS_TO_SEND_COUNT)) {
kaaClient.addLogRecord(log);
}
Expand All @@ -58,6 +65,7 @@ public static void main(String[] args) {
e.printStackTrace();
}

//stoping client
kaaClient.stop();
LOGGER.info("Data collection demo stopped");
}
Expand All @@ -70,6 +78,8 @@ public static List<LogData> getLogs(int logCount) {
return logs;
}

//default upload strategy sends logs after some count or some logs size reached
//this one sends every log record
private static class OneLogUploadStrategy extends DefaultLogUploadStrategy {
@Override
public LogUploadStrategyDecision isUploadNeeded(LogStorageStatus status) {
Expand Down
29 changes: 29 additions & 0 deletions examples/jeventdemo/resources/projects.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!--
Copyright 2014-2015 CyberVision, Inc.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
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.
-->

<projectsConfig>
<project id="jevent_demo">
<name>Java event demo</name>
<description>Application on java platform demonstrating event subsystem (IoT)</description>
<platform>JAVA</platform>
<sourceArchive>java/jevent_demo.tar.gz</sourceArchive>
<projectFolder>jevent_demo/JEventDemo</projectFolder>
<sdkLibDir>jevent_demo/JEventDemo/lib</sdkLibDir>
<destBinaryFile>jevent_demo/JEventDemo/build/jar/EventDemo.jar</destBinaryFile>
</project>
</projectsConfig>
Expand Up @@ -40,6 +40,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* This class receives Kaa events and user attach/detach callbacks and dispatch them to other application components via event bus.
*/
public class EventDemo {

private static final Logger LOG = LoggerFactory.getLogger(EventDemo.class);
Expand Down
29 changes: 29 additions & 0 deletions examples/notificationdemo/resources/projects.xml
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!--
Copyright 2014-2015 CyberVision, Inc.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
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.
-->

<projectsConfig>
<project id="notification_demo">
<name>Android notification demo</name>
<description>Application on android platform demonstrating notification subsystem (IoT)</description>
<platform>ANDROID</platform>
<sourceArchive>android/notification_demo.tar.gz</sourceArchive>
<projectFolder>notification_demo/NotificationDemo</projectFolder>
<sdkLibDir>notification_demo/NotificationDemo/libs</sdkLibDir>
<destBinaryFile>notification_demo/NotificationDemo/bin/KaaNotificationDemo-debug.apk</destBinaryFile>
</project>
</projectsConfig>
Expand Up @@ -22,7 +22,7 @@
public class DemoBuildersRegistry {

private static final List<DemoBuilder> demoBuilders = new ArrayList<>();

static {
//ANDROID DEMOS
demoBuilders.add(new NotificationDemoBuilder());
Expand All @@ -37,9 +37,9 @@ public class DemoBuildersRegistry {
demoBuilders.add(new JEventDemoBuilder());
demoBuilders.add(new JDataCollectionDemoBuider());
}

public static List<DemoBuilder> getRegisteredDemoBuilders() {
return demoBuilders;
}

}
Expand Up @@ -37,6 +37,10 @@ public class JDataCollectionDemoBuider extends AbstractDemoBuilder{

private static final Logger logger = LoggerFactory.getLogger(JDataCollectionDemoBuider.class);

protected JDataCollectionDemoBuider() {
super("demo/photoframe");
}

@Override
protected void buildDemoApplicationImpl(AdminClient client) throws Exception {

Expand Down Expand Up @@ -81,17 +85,4 @@ protected void buildDemoApplicationImpl(AdminClient client) throws Exception {
logger.info("Finished loading 'Java Data Collection Demo Application' data.");
}

@Override
protected void setupProjectConfigs() {
Project projectConfig = new Project();
projectConfig.setId("jdatacollection_demo");
projectConfig.setName("Java data collection demo");
projectConfig.setDescription("Application on java platform demonstrating data collection subsystem (IoT)");
projectConfig.setPlatform(Platform.JAVA);
projectConfig.setSourceArchive("java/jdatacollection_demo.tar.gz");
projectConfig.setProjectFolder("jdatacollection_demo/JDataCollectionDemo");
projectConfig.setSdkLibDir("jdatacollection_demo/JDataCollectionDemo/lib");
projectConfig.setDestBinaryFile("jdatacollection_demo/JDataCollectionDemo/build/jar/DataCollectionDemo.jar");
projectConfigs.add(projectConfig);
}
}
Expand Up @@ -35,10 +35,14 @@
import java.util.ArrayList;
import java.util.List;

public class JEventDemoBuilder extends AbstractDemoBuilder{
public class JEventDemoBuilder extends AbstractDemoBuilder {

private static final Logger logger = LoggerFactory.getLogger(JEventDemoBuilder.class);

protected JEventDemoBuilder() {
super("demo/photoframe");
}

@Override
protected void buildDemoApplicationImpl(AdminClient client) throws Exception {

Expand Down Expand Up @@ -89,42 +93,5 @@ protected void buildDemoApplicationImpl(AdminClient client) throws Exception {
logger.info("Finished loading 'Java Event Demo Application' data.");
}

private ApplicationEventFamilyMapDto mapEventClassFamily(AdminClient client, ApplicationDto application, EventClassFamilyDto eventClassFamily) throws Exception {
List<EventClassDto> eventClasses =
client.getEventClassesByFamilyIdVersionAndType(eventClassFamily.getId(), 1, EventClassType.EVENT);

ApplicationEventFamilyMapDto aefMap = new ApplicationEventFamilyMapDto();
aefMap.setApplicationId(application.getId());
aefMap.setEcfId(eventClassFamily.getId());
aefMap.setEcfName(eventClassFamily.getName());
aefMap.setVersion(1);

List<ApplicationEventMapDto> eventMaps = new ArrayList<>(eventClasses.size());
for (EventClassDto eventClass : eventClasses) {
ApplicationEventMapDto eventMap = new ApplicationEventMapDto();
eventMap.setEventClassId(eventClass.getId());
eventMap.setFqn(eventClass.getFqn());
eventMap.setAction(ApplicationEventAction.BOTH);
eventMaps.add(eventMap);
}

aefMap.setEventMaps(eventMaps);
aefMap = client.editApplicationEventFamilyMap(aefMap);
return aefMap;
}


@Override
protected void setupProjectConfigs() {
Project projectConfig = new Project();
projectConfig.setId("jevent_demo");
projectConfig.setName("Java event demo");
projectConfig.setDescription("Application on java platform demonstrating event subsystem (IoT)");
projectConfig.setPlatform(Platform.JAVA);
projectConfig.setSourceArchive("java/jevent_demo.tar.gz");
projectConfig.setProjectFolder("jevent_demo/JEventDemo");
projectConfig.setSdkLibDir("jevent_demo/JEventDemo/lib");
projectConfig.setDestBinaryFile("jevent_demo/JEventDemo/build/jar/EventDemo.jar");
projectConfigs.add(projectConfig);
}
}
Expand Up @@ -19,8 +19,6 @@
import org.kaaproject.kaa.common.dto.NotificationSchemaDto;
import org.kaaproject.kaa.common.dto.admin.SdkPlatform;
import org.kaaproject.kaa.common.dto.user.UserVerifierDto;
import org.kaaproject.kaa.sandbox.demo.projects.Platform;
import org.kaaproject.kaa.sandbox.demo.projects.Project;
import org.kaaproject.kaa.server.common.admin.AdminClient;
import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithm;
import org.kaaproject.kaa.server.common.core.algorithms.generation.DefaultRecordGenerationAlgorithmImpl;
Expand All @@ -37,7 +35,7 @@ public class NotificationDemoBuilder extends AbstractDemoBuilder {
private static final Logger logger = LoggerFactory.getLogger(NotificationDemoBuilder.class);

protected NotificationDemoBuilder() {
super();
super("demo/photoframe");
}

@Override
Expand Down Expand Up @@ -68,7 +66,7 @@ protected void buildDemoApplicationImpl(AdminClient client) throws Exception {
notificationSchemaDto.setDescription("Notification schema describing incoming notifications");
notificationSchemaDto = client.createNotificationSchema(notificationSchemaDto, "demo/notification/notificationSchema.json");
sdkKey.setNotificationSchemaVersion(notificationSchemaDto.getMajorVersion());


TrustfulVerifierConfig trustfulVerifierConfig = new TrustfulVerifierConfig();
UserVerifierDto trustfulUserVerifier = new UserVerifierDto();
Expand All @@ -87,17 +85,4 @@ protected void buildDemoApplicationImpl(AdminClient client) throws Exception {
logger.info("Finished loading 'Android Notification Demo Application' data.");
}

@Override
protected void setupProjectConfigs() {
Project projectConfig = new Project();
projectConfig.setId("notification_demo");
projectConfig.setName("Android notification demo");
projectConfig.setDescription("Application on android platform demonstrating notification subsystem (IoT)");
projectConfig.setPlatform(Platform.ANDROID);
projectConfig.setSourceArchive("android/notification_demo.tar.gz");
projectConfig.setProjectFolder("notification_demo/NotificationDemo");
projectConfig.setSdkLibDir("notification_demo/NotificationDemo/libs");
projectConfig.setDestBinaryFile("notification_demo/NotificationDemo/bin/KaaNotificationDemo-debug.apk");
projectConfigs.add(projectConfig);
}
}
Expand Up @@ -34,60 +34,60 @@
import org.slf4j.LoggerFactory;

public class PhotoFrameDemoBuilder extends AbstractDemoBuilder {

private static final Logger logger = LoggerFactory.getLogger(PhotoFrameDemoBuilder.class);

protected PhotoFrameDemoBuilder() {
super("demo/photoframe");
}

@Override
protected void buildDemoApplicationImpl(AdminClient client) throws Exception {

logger.info("Loading 'Photo Frame Demo Application' data...");

loginTenantAdmin(client);

EventClassFamilyDto photoFrameEventClassFamily = new EventClassFamilyDto();
photoFrameEventClassFamily.setName("Photo Frame Event Class Family");
photoFrameEventClassFamily.setNamespace("org.kaaproject.kaa.demo.photoframe");
photoFrameEventClassFamily.setClassName("PhotoFrameEventClassFamily");
photoFrameEventClassFamily = client.editEventClassFamily(photoFrameEventClassFamily);
client.addEventClassFamilySchema(photoFrameEventClassFamily.getId(), getResourcePath("photoFrameEventClassFamily.json"));

ApplicationDto photoFrameApplication = new ApplicationDto();
photoFrameApplication.setName("Photo frame");
photoFrameApplication = client.editApplication(photoFrameApplication);

sdkKey.setApplicationId(photoFrameApplication.getId());
sdkKey.setProfileSchemaVersion(1);
sdkKey.setConfigurationSchemaVersion(1);
sdkKey.setNotificationSchemaVersion(1);
sdkKey.setLogSchemaVersion(1);
sdkKey.setTargetPlatform(SdkPlatform.ANDROID);

loginTenantDeveloper(client);

ApplicationEventFamilyMapDto photoFrameAefMap = mapEventClassFamily(client, photoFrameApplication, photoFrameEventClassFamily);

List<String> aefMapIds = new ArrayList<>();
aefMapIds.add(photoFrameAefMap.getId());
sdkKey.setAefMapIds(aefMapIds);
TrustfulVerifierConfig trustfulVerifierConfig = new TrustfulVerifierConfig();

TrustfulVerifierConfig trustfulVerifierConfig = new TrustfulVerifierConfig();
UserVerifierDto trustfulUserVerifier = new UserVerifierDto();
trustfulUserVerifier.setApplicationId(photoFrameApplication.getId());
trustfulUserVerifier.setName("Trustful verifier");
trustfulUserVerifier.setPluginClassName(trustfulVerifierConfig.getPluginClassName());
trustfulUserVerifier.setPluginTypeName(trustfulVerifierConfig.getPluginTypeName());
RawSchema rawSchema = new RawSchema(trustfulVerifierConfig.getPluginConfigSchema().toString());
DefaultRecordGenerationAlgorithm<RawData> algotithm =
new DefaultRecordGenerationAlgorithmImpl<>(rawSchema, new RawDataFactory());
DefaultRecordGenerationAlgorithm<RawData> algotithm =
new DefaultRecordGenerationAlgorithmImpl<>(rawSchema, new RawDataFactory());
RawData rawData = algotithm.getRootData();
trustfulUserVerifier.setJsonConfiguration(rawData.getRawData());
trustfulUserVerifier.setJsonConfiguration(rawData.getRawData());
trustfulUserVerifier = client.editUserVerifierDto(trustfulUserVerifier);
sdkKey.setDefaultVerifierToken(trustfulUserVerifier.getVerifierToken());

logger.info("Finished loading 'Photo Frame Demo Application' data.");
}

Expand Down
Expand Up @@ -31,13 +31,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpHost;
import org.kaaproject.kaa.common.dto.ApplicationDto;
import org.kaaproject.kaa.common.dto.ConfigurationDto;
import org.kaaproject.kaa.common.dto.ConfigurationRecordDto;
import org.kaaproject.kaa.common.dto.ConfigurationSchemaDto;
import org.kaaproject.kaa.common.dto.EndpointGroupDto;
import org.kaaproject.kaa.common.dto.ProfileFilterDto;
import org.kaaproject.kaa.common.dto.ProfileSchemaDto;
import org.kaaproject.kaa.common.dto.*;
import org.kaaproject.kaa.common.dto.admin.AuthResultDto;
import org.kaaproject.kaa.common.dto.admin.ResultCode;
import org.kaaproject.kaa.common.dto.admin.SdkKey;
Expand Down

0 comments on commit 5acd2a8

Please sign in to comment.