Skip to content

Commit

Permalink
Stabilised inventory (#237)
Browse files Browse the repository at this point in the history
* Stabilised inventory
updating license

* Removed Codacy Warning
  • Loading branch information
pg301 authored and KeenWarrior committed Jul 15, 2017
1 parent 213ddde commit 1e02662
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 45 deletions.
1 change: 1 addition & 0 deletions mobile/build.gradle
Expand Up @@ -184,6 +184,7 @@ dependencies {
compile "frankiesardo:icepick:3.1.0"
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
compile 'com.google.code.gson:gson:2.6.1'

testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
testCompile 'junit:junit:4.12'
Expand Down
Expand Up @@ -67,6 +67,7 @@ public static RefWatcher getRefWatcher(Context context) {

public static void setUpRetrofit(String url, final String username, final String password) {


OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(new Interceptor() {
@Override
Expand Down
Expand Up @@ -73,13 +73,13 @@ private void setUpMetric() {

private Fragment getMetricFragment() {
switch (getMetric().getConfiguration().getType()) {
case AVAILABILITY:
case "AVAILABILITY":
return Fragments.Builder.buildMetricAvailabilityFragment(getMetric());

case GAUGE:
case "GAUGE":
return Fragments.Builder.buildMetricGaugeFragment(getMetric());

case COUNTER:
case "COUNTER":
return Fragments.Builder.buildMetricCounterFragment(getMetric());

default:
Expand Down
Expand Up @@ -22,6 +22,7 @@
import android.support.annotation.NonNull;
import android.support.annotation.RequiresPermission;
import android.support.v4.app.Fragment;
import android.util.Log;

import org.hawkular.client.android.HawkularApplication;
import org.hawkular.client.android.backend.model.Alert;
Expand Down Expand Up @@ -150,6 +151,12 @@ public void getFeeds(@NonNull retrofit2.Callback<Feed> callback) {
call.enqueue(callback);
}

public void getMetricType(@NonNull retrofit2.Callback callback, @NonNull InventoryResponseBody body){
MetricService service = retrofit.create(MetricService.class);
Call call = service.getMetricType(body);
call.enqueue(callback);
}

public void getOpreations(@NonNull AbstractCallback<List<Operation>> callback, Resource resource) {
// TODO : after moving to retrofit complete
}
Expand All @@ -171,8 +178,10 @@ public void getRecResourcesFromFeed(@NonNull retrofit2.Callback callback, Resour
}


public void getMetricsFromFeed(@NonNull AbstractCallback<List<Metric>> callback, Resource resource) {
// TODO : after moving to retrofit complete
public void getMetricsFromFeed(@NonNull retrofit2.Callback<List<Resource>> callback, @NonNull InventoryResponseBody body) {
MetricService service = retrofit.create(MetricService.class);
Call call = service.getMetricFromFeed(body);
call.enqueue(callback);
}


Expand All @@ -191,12 +200,13 @@ public void getMetricData(@NonNull Metric metric, long bucket,

MetricService service = retrofit.create(MetricService.class);

Log.d("BackendClient",metric.getConfiguration().getType());
Call call = null;
if (metric.getConfiguration().getType()== MetricType.AVAILABILITY) {
if (metric.getConfiguration().getType().equalsIgnoreCase("AVAILABILITY")) {
call = service.getMetricAvailabilityData(metric.getId(), parameters);
} else if (metric.getConfiguration().getType()== MetricType.COUNTER) {
} else if (metric.getConfiguration().getType().equalsIgnoreCase("COUNTER")){
call = service.getMetricAvailabilityData(metric.getId(), parameters);
} else if (metric.getConfiguration().getType()== MetricType.GAUGE) {
} else if (metric.getConfiguration().getType().equalsIgnoreCase("GAUGE")) {
call = service.getMetricAvailabilityData(metric.getId(), parameters);
}

Expand Down
Expand Up @@ -24,22 +24,32 @@
import android.support.annotation.VisibleForTesting;

public final class MetricConfiguration implements Parcelable {

@SerializedName("type")
private MetricType type;
private String type;

@VisibleForTesting
public MetricConfiguration(@NonNull MetricType type) {
public MetricConfiguration(String type) {
this.type = type;
}

public MetricType getType() {
return type;
protected MetricConfiguration(Parcel in) {
type = in.readString();
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(type);
}

public static Creator<MetricConfiguration> CREATOR = new Creator<MetricConfiguration>() {
@Override
public int describeContents() {
return 0;
}

public static final Creator<MetricConfiguration> CREATOR = new Creator<MetricConfiguration>() {
@Override
public MetricConfiguration createFromParcel(Parcel parcel) {
return new MetricConfiguration(parcel);
public MetricConfiguration createFromParcel(Parcel in) {
return new MetricConfiguration(in);
}

@Override
Expand All @@ -48,17 +58,12 @@ public MetricConfiguration[] newArray(int size) {
}
};

private MetricConfiguration(Parcel parcel) {
this.type = parcel.readParcelable(MetricType.class.getClassLoader());
public String getType() {
return type;
}

@Override
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeParcelable(type, flags);
public void setType(String type) {
this.type = type;
}

@Override
public int describeContents() {
return 0;
}
}
@@ -0,0 +1,93 @@
/*
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.
*/
package org.hawkular.client.android.backend.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
* Created by pallavi on 14/07/17.
*/

public class MetricInfo implements Parcelable{
private String id;
private String name;

public MetricInfo(String id, String name, String metricTypePath) {
this.id = id;
this.name = name;
this.metricTypePath = metricTypePath;
}

private String metricTypePath;

public MetricInfo(Parcel in) {
id = in.readString();
name = in.readString();
metricTypePath = in.readString();
}



public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getMetricTypePath() {
return metricTypePath;
}

public void setMetricTypePath(String metricTypePath) {
this.metricTypePath = metricTypePath;
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeString(name);
dest.writeString(metricTypePath);
}
public static final Creator<MetricInfo> CREATOR = new Creator<MetricInfo>() {
@Override
public MetricInfo createFromParcel(Parcel in) {
return new MetricInfo(in);
}

@Override
public MetricInfo[] newArray(int size) {
return new MetricInfo[size];
}
};

}
@@ -0,0 +1,72 @@
/*
* Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.
*/
package org.hawkular.client.android.backend.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
* Created by pallavi on 14/07/17.
*/

public class MetricTemp implements Parcelable{

MetricInfo metricInfo;

public MetricTemp(MetricInfo metricInfo) {
this.metricInfo = metricInfo;
}

protected MetricTemp(Parcel in) {
metricInfo = in.readParcelable(MetricInfo.class.getClassLoader());
}

public static final Creator<MetricTemp> CREATOR = new Creator<MetricTemp>() {
@Override
public MetricTemp createFromParcel(Parcel in) {
return new MetricTemp(in);
}

@Override
public MetricTemp[] newArray(int size) {
return new MetricTemp[size];
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(metricInfo, flags);
}

public MetricInfo getMetricInfo() {
return metricInfo;
}

public void setMetricInfo(MetricInfo metricInfo) {
this.metricInfo = metricInfo;
}

public static Creator<MetricTemp> getCREATOR() {
return CREATOR;
}
}

0 comments on commit 1e02662

Please sign in to comment.