Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
fix(log): add log data structure
Browse files Browse the repository at this point in the history
Signed-off-by: Rafa Hernandez <rhernandez@teclib.com>
  • Loading branch information
rafaelje authored and Ivan Del Pino committed Dec 5, 2018
1 parent 1b1ea98 commit c7dcfcd
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 2 deletions.
@@ -0,0 +1,55 @@
/*
* Copyright Teclib. All rights reserved.
*
* This file is part of flyve-mdm-android
*
* flyve-mdm-android is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author @rafaelje
* @copyright Copyright Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/flyve-mdm-android
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

package org.flyve.mdm.agent.data.database;

import android.content.Context;

import org.flyve.mdm.agent.data.database.entity.MDMLog;
import org.flyve.mdm.agent.data.database.setup.AppDataBase;

public class MDMLogData {

private AppDataBase dataBase;

public MDMLogData(Context context) {
dataBase = AppDataBase.getAppDatabase(context);
}

public MDMLog[] getAllFiles() {
return dataBase.MDMLogDao().loadAll();
}

public void deleteAll() {
dataBase.MDMLogDao().deleteAll();
}

public void addLog(String message) {
MDMLog log = new MDMLog();
log.description = message;
dataBase.MDMLogDao().insert(log);
}
}
@@ -0,0 +1,47 @@
/*
* Copyright Teclib. All rights reserved.
*
* Flyve MDM is a mobile device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author Rafael Hernandez
* @copyright Copyright Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/android-mdm-agent
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

package org.flyve.mdm.agent.data.database.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import org.flyve.mdm.agent.data.database.entity.MDMLog;

@Dao
public interface MDMLogDao {

@Insert
void insert(MDMLog... log);

@Update
void update(MDMLog... log);

@Query("SELECT * FROM log")
MDMLog[] loadAll();

@Query("DELETE FROM log")
void deleteAll();
}
@@ -0,0 +1,42 @@
/*
* Copyright Teclib. All rights reserved.
*
* Flyve MDM is a mobile device management software.
*
* Flyve MDM is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* Flyve MDM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ------------------------------------------------------------------------------
* @author Rafael Hernandez
* @copyright Copyright Teclib. All rights reserved.
* @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
* @link https://github.com/flyve-mdm/android-mdm-agent
* @link https://flyve-mdm.com
* ------------------------------------------------------------------------------
*/

package org.flyve.mdm.agent.data.database.entity;

import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;

@Entity (tableName = "log")
public class MDMLog {

@PrimaryKey (autoGenerate = true)
@ColumnInfo (name = "id")
public int id;

@ColumnInfo (name = "description")
public String description;

@ColumnInfo (name = "type")
public String type;
}
Expand Up @@ -28,17 +28,19 @@
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;

import org.flyve.mdm.agent.data.database.entity.File;
import org.flyve.mdm.agent.data.database.dao.ApplicationDao;
import org.flyve.mdm.agent.data.database.dao.FileDao;
import org.flyve.mdm.agent.data.database.dao.MDMLogDao;
import org.flyve.mdm.agent.data.database.dao.MQTTDao;
import org.flyve.mdm.agent.data.database.dao.PoliciesDao;
import org.flyve.mdm.agent.data.database.entity.Application;
import org.flyve.mdm.agent.data.database.entity.File;
import org.flyve.mdm.agent.data.database.entity.MDMLog;
import org.flyve.mdm.agent.data.database.entity.MQTT;
import org.flyve.mdm.agent.data.database.entity.Policies;


@Database(entities = {Application.class, MQTT.class, Policies.class, File.class}, version = 8, exportSchema = false)
@Database(entities = {Application.class, MQTT.class, Policies.class, File.class, MDMLog.class}, version = 9, exportSchema = false)
public abstract class AppDataBase extends RoomDatabase {

private static AppDataBase instance;
Expand All @@ -47,6 +49,7 @@ public abstract class AppDataBase extends RoomDatabase {
public abstract MQTTDao MQTTDao();
public abstract PoliciesDao PoliciesDao();
public abstract FileDao FileDao();
public abstract MDMLogDao MDMLogDao();

public static AppDataBase getAppDatabase(Context context) {
if (instance == null) {
Expand Down

0 comments on commit c7dcfcd

Please sign in to comment.