ページの先頭行へ戻る
Interstage AR Processing Server V1.0.1 開発ガイド
FUJITSU Software

3.3.3 データの登録例

サンプル用利用者定義テーブル「usr_sample」を例に、それぞれ登録する方法を記述しています。

3.3.3.1 qentityの登録

usr_sampleにqentityを登録する方法について、説明します。

  1. 登録するqentityのJSON文字列を作成

    var qentity = new Object();
    qentity.qtypeName = “usr_sample”;
    var body = JSON.stringify(qentity);  // {“qtypeName” : “usr_sample”}
  2. AR.Data.postServerData()を使用して登録

    AR.Data.postArServerData(“qentities”, body, onSuccess, onError);
  3. 登録成功時のレスポンスはqentityのJSONオブジェクトです。自動採番されたidとversionが付加されています。qvalueの登録や削除時に使用します。

    {“id”:1, “qtypeName”:“usr_sample”, “version”:1}

3.3.3.2 qvalueの登録

usr_sampleのusr_nameに値を登録します。

  1. 登録するqvalueのJSON文字列を作成

    var qvalue = new Object();
    qvalue.qtypeName = “usr_sample”;
    qvalue.qentityId = 1; //登録されているqentityのIdを指定してください。
    qvalue.qattributeName = “usr_name”;
    qvalue.stringValue = “ユーザーA”; 
    qvalue.longValue = null;  //使用しないValueにはnullを指定してください。
    qvalue.floatValue = null;  //使用しないValueにはnullを指定してください。
    var body = JSON.stringify(qvalue);  // {“qtypeName”:”usr_sample”, “qentityId”:1, “qattributeName”:”usr_name”, “stringValue”:”ユーザーA”, “longValue”:null, “floatValue”:null}
  2. AR.Data.postServerData()を使用して登録します。

    AR.Data.postArServerData(“qvalues”, body, onSuccess, onError);
  3. 登録成功時のレスポンスにqvalueのJSONオブジェクトです。自動採番されたversionが付加されています。削除時に使用します。

    {“qtypeName”:”usr_sample”, “qentityId”:1, “qattributeName”:”usr_name”, “stringValue”:”ユーザーA”, “longValue”:null, “floatValue”:null, “version”:1}

3.3.3.3 quadの登録

usr_sampleにquadを登録する方法について説明します。

  1. 各attributeのqvalueを作成します。qentityIdとversionは自動採番されるので指定しないでください。

    var arId = new Object();
    arId.qtypeName = "usr_sample";
    arId.qattributeName = "ar_id";
    arId.stringValue = null; 
    arId.longValue = 1;  //使用しないValueにはnullを指定してください。
    arId.floatValue = null;  //使用しないValueにはnullを指定してください。
    var arName = new Object();
    arName.qtypeName = "usr_sample";
    arName.qattributeName = "ar_name";
    arName.stringValue = "点検結果"; 
    arName.longValue = null;  //使用しないValueにはnullを指定してください。
    arName.floatValue = null;  //使用しないValueにはnullを指定してください。
    
    var arDescription = new Object();
    arDescription.qtypeName = "usr_sample";
    arDescription.qattributeName = "ar_description";
    arDescription.stringValue = "AR業務サンプルアプリケーションの点検結果です。";
    arDescription.longValue = null;
    arDescription.floatValue = null;
    
    var arRegistrationtime = new Object();
    arRegistrationtime.qtypeName = "usr_sample";
    arRegistrationtime.qattributeName = "ar_registrationtime";
    arRegistrationtime.stringValue = null;
    arRegistrationtime.longValue = new Date().getTime();
    arRegistrationtime.floatValue = null;
    
    var arModificationtime = new Object();
    arModificationtime.qtypeName = "usr_sample";
    arModificationtime.qattributeName = "ar_modificationtime";
    arModificationtime.stringValue = null;
    arModificationtime.longValue = new Date().getTime();
    arModificationtime.floatValue = null;
    
    var usrName = new Object();
    usrName.qtypeName = "usr_sample";
    usrName.qattributeName = "usr_name";
    usrName.stringValue = "ユーザーA"; 
    usrName.longValue = null;  //使用しないValueにはnullを指定してください。
    usrName.floatValue = null;  //使用しないValueにはnullを指定してください。
    
    var usrTemperature = new Object();
    usrTemperature.qtypeName = "usr_sample";
    usrTemperature.qattributeName = "usr_temperature";
    usrTemperature.stringValue = null; //使用しないValueにはnullを指定してください。
    usrTemperature.longValue = 10; 
    usrTemperature.floatValue = null; //使用しないValueにはnullを指定してください。
  2. quadのJSON文字列を作成します。idとversionは自動採番されるので指定しないでください。

    var quad = new Object();
    quad.qtypeName = "usr_sample";
    quad.qvalues = [arId, arName, arDescription, arRegistrationtime, arModificationtime, usrName, usrTemperature]; //作成したattributeを配列にしてください。
    var body  =  JSON.stringify(quad); //{"qtypeName" : "usr_sample"  ,  "qvalues" : [{"qtypeName" : "usr_sample"  , "qattributeName"  :  "ar_id", ・・・}, ・・・]}
  3. AR.Data.postServerData()を使用して登録します。

    AR.Data.postArServerData(“quads”, body, onSuccess, onError);
  4. 登録成功時のレスポンスはquadのJSONオブジェクトです。自動採番されたQEntityIdとversionが付加されています。削除時に使用します。