blob: 0c8e03e022fae2f50bbb7f477ca68aa69f375d24 [file] [log] [blame]
// Copyright (C) 2012 The Android Open Source Project
//
// 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 com.google.gerrit.client.changes;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
import java.sql.Timestamp;
import java.util.Set;
public class ChangeInfo extends JavaScriptObject {
public final Project.NameKey project_name_key() {
return new Project.NameKey(project());
}
public final Change.Id legacy_id() {
return new Change.Id(_number());
}
public final Timestamp created() {
Timestamp ts = _get_cts();
if (ts == null) {
ts = JavaSqlTimestamp_JsonSerializer.parseTimestamp(createdRaw());
_set_cts(ts);
}
return ts;
}
private final native Timestamp _get_cts() /*-{ return this._cts; }-*/;
private final native void _set_cts(Timestamp ts) /*-{ this._cts = ts; }-*/;
public final Timestamp updated() {
return JavaSqlTimestamp_JsonSerializer.parseTimestamp(updatedRaw());
}
public final String id_abbreviated() {
return new Change.Key(id()).abbreviate();
}
public final Change.Status status() {
return Change.Status.valueOf(statusRaw());
}
public final Set<String> labels() {
return Natives.keys(labels0());
}
public final native String project() /*-{ return this.project; }-*/;
public final native String branch() /*-{ return this.branch; }-*/;
public final native String topic() /*-{ return this.topic; }-*/;
public final native String id() /*-{ return this.id; }-*/;
private final native String statusRaw() /*-{ return this.status; }-*/;
public final native String subject() /*-{ return this.subject; }-*/;
public final native AccountInfo owner() /*-{ return this.owner; }-*/;
private final native String createdRaw() /*-{ return this.created; }-*/;
private final native String updatedRaw() /*-{ return this.updated; }-*/;
public final native boolean starred() /*-{ return this.starred ? true : false; }-*/;
public final native boolean reviewed() /*-{ return this.reviewed ? true : false; }-*/;
public final native String _sortkey() /*-{ return this._sortkey; }-*/;
private final native JavaScriptObject labels0() /*-{ return this.labels; }-*/;
public final native LabelInfo label(String n) /*-{ return this.labels[n]; }-*/;
final native int _number() /*-{ return this._number; }-*/;
final native boolean _more_changes()
/*-{ return this._more_changes ? true : false; }-*/;
protected ChangeInfo() {
}
public static class AccountInfo extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
protected AccountInfo() {
}
}
public static class LabelInfo extends JavaScriptObject {
public final SubmitRecord.Label.Status status() {
if (approved() != null) {
return SubmitRecord.Label.Status.OK;
} else if (rejected() != null) {
return SubmitRecord.Label.Status.REJECT;
} else if (optional()) {
return SubmitRecord.Label.Status.MAY;
} else {
return SubmitRecord.Label.Status.NEED;
}
}
public final native String name() /*-{ return this._name; }-*/;
public final native AccountInfo approved() /*-{ return this.approved; }-*/;
public final native AccountInfo rejected() /*-{ return this.rejected; }-*/;
public final native AccountInfo recommended() /*-{ return this.recommended; }-*/;
public final native AccountInfo disliked() /*-{ return this.disliked; }-*/;
public final native boolean optional() /*-{ return this.optional ? true : false; }-*/;
final native short _value()
/*-{
if (this.value) return this.value;
if (this.disliked) return -1;
if (this.recommended) return 1;
return 0;
}-*/;
protected LabelInfo() {
}
}
}