diff --git a/app/build.gradle b/app/build.gradle index 8f90306..2bf4ec3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,4 +45,15 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' -} \ No newline at end of file +} +//room用の依存関係を追加 +dependencies { + def room_version = "2.4.1" + + implementation "androidx.room:room-runtime:$room_version" + annotationProcessor "androidx.room:room-compiler:$room_version" +} +dependencies { + implementation 'com.google.code.gson:gson:2.8.8' +} + diff --git a/app/src/main/java/com/example/oplogy/FirestoreReception.java b/app/src/main/java/com/example/oplogy/FirestoreReception.java index 9f50d67..fd5abc5 100644 --- a/app/src/main/java/com/example/oplogy/FirestoreReception.java +++ b/app/src/main/java/com/example/oplogy/FirestoreReception.java @@ -36,26 +36,8 @@ public class FirestoreReception { Map data = document.getData(); // デバッグ用のログ出力 - Log.d("FirestoreReception", "Document ID: " + document.getId()); +// Log.d("FirestoreReception", "Document ID: " + document.getId()); Log.d("FirestoreReception", "Data: " + data); - - // ここでデータを取得し、必要に応じて処理を行います -// String parentName = (String) data.get("patronName"); -// String childName = (String) data.get("childName"); -// String studentId = (String) data.get("studentNumber"); -//// Timestamp address = (Timestamp) data.get("address"); -// List firstDay = (List) data.get("firstDay"); -// List secondDay = (List) data.get("secondDay"); -// List thirdDay = (List) data.get("thirdDay"); -// -// // 取得したデータを使って必要な処理を行う -// Log.d("FirestoreReception", "ParentName: " + parentName); -// Log.d("FirestoreReception", "ChildName: " + childName); -// Log.d("FirestoreReception", "StudentNumber: " + studentId); -//// Log.d("FirestoreReception", "Address: " + address.toDate()); -// Log.d("FirestoreReception", "First Day: " + firstDay); -// Log.d("FirestoreReception", "Second Day: " + secondDay); -// Log.d("FirestoreReception", "Third Day: " + thirdDay); } } else { Log.w("FirestoreReception", "Error getting documents.", task.getException()); diff --git a/app/src/main/java/com/example/oplogy/FormTable.java b/app/src/main/java/com/example/oplogy/FormTable.java new file mode 100644 index 0000000..491da55 --- /dev/null +++ b/app/src/main/java/com/example/oplogy/FormTable.java @@ -0,0 +1,26 @@ +package com.example.oplogy; + +import androidx.room.ColumnInfo; +import androidx.room.Entity; +import androidx.room.ForeignKey; +import androidx.room.PrimaryKey; +import androidx.room.TypeConverters; + +import java.util.Map; + +@Entity( + foreignKeys = @ForeignKey(entity = SetupTable.class,//外部キーとしてSetupTableクラスを指定 + parentColumns = "id",//親クラスのidと結びつけ + childColumns = "data",//子クラスのprofileIdと結びつけ + onDelete = ForeignKey.CASCADE//親クラスが削除されたら子クラスも削除 + ) +) +public class FormTable { + @PrimaryKey(autoGenerate = true) + public int id; + + @ColumnInfo(name = "data") + public Map data; + + // Getters and setters if needed +} diff --git a/app/src/main/java/com/example/oplogy/MainActivity.java b/app/src/main/java/com/example/oplogy/MainActivity.java index d7dc725..4a76271 100644 --- a/app/src/main/java/com/example/oplogy/MainActivity.java +++ b/app/src/main/java/com/example/oplogy/MainActivity.java @@ -63,10 +63,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe submission = findViewById(R.id.submission); submission.setOnClickListener(this); -// firestoreの受信関連 +// firestoreの受信関連の宣言 db = FirebaseFirestore.getInstance(); firestoreReception = new FirestoreReception(); - +// 受信するメソッドの呼び出し firestoreReception.getDocumentsByClassId(100); diff --git a/app/src/main/java/com/example/oplogy/SetUpActivity.java b/app/src/main/java/com/example/oplogy/SetUpActivity.java deleted file mode 100644 index f775443..0000000 --- a/app/src/main/java/com/example/oplogy/SetUpActivity.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.oplogy; - -import androidx.appcompat.app.AppCompatActivity; - -import android.os.Bundle; - -public class SetUpActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_set_up); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/oplogy/SetupTable.java b/app/src/main/java/com/example/oplogy/SetupTable.java new file mode 100644 index 0000000..2f5a7c2 --- /dev/null +++ b/app/src/main/java/com/example/oplogy/SetupTable.java @@ -0,0 +1,88 @@ +package com.example.oplogy; + + +import androidx.room.ColumnInfo; +import androidx.room.Embedded; +import androidx.room.Entity; +import androidx.room.ForeignKey; +import androidx.room.Ignore; +import androidx.room.PrimaryKey; +import androidx.room.Relation; + +import java.util.Date; +import java.util.List; + +@Entity(tableName = "teacher_table") +public class SetupTable { + //フィールド + @PrimaryKey() + public int classId; + @ColumnInfo(name = "teacher_name") + public String teacherName; + @ColumnInfo(name = "startpoint") + public String startpoint; + @ColumnInfo(name = "subject") + public String startTime; + @ColumnInfo(name = "end_time") + public String endTime; + @ColumnInfo(name = "break_time") + public String breakTime; + @ColumnInfo(name = "total_students") + public int totalStudents; + + //コンストラクタ + public SetupTable(int classId,String startpoint , String teacherName, String startTime, String endTime, String breakTime, int totalStudents) { + this.classId = classId; + this.startpoint = startpoint; + this.teacherName = teacherName; + this.startTime = startTime; + this.endTime = endTime; + this.breakTime = breakTime; + this.totalStudents = totalStudents; + } + + //ゲッター + public int getClassId() { + return classId; + } + public String getTeacherName() { + return teacherName; + } + public String getStartTime() { + return startTime; + } + public String getEndTime() { + return endTime; + } + public String getBreakTime() { + return breakTime; + } + public int getTotalStudents() { + return totalStudents; + } + public String getStartpoint() { + return startpoint; + } + //セッター + public void setClassId(int classId) { + this.classId = classId; + } + public void setTeacherName(String teacherName) { + this.teacherName = teacherName; + } + public void setStartTime(String startTime) { + this.startTime = startTime; + } + public void setEndTime(String endTime) { + this.endTime = endTime; + } + public void setBreakTime(String breakTime) { + this.breakTime = breakTime; + } + public void setTotalStudents(int totalStudents) { + this.totalStudents = totalStudents; + } + public void setStartpoint(String startpoint) { + this.startpoint = startpoint; + } +} \ No newline at end of file