-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
11 changed files
with
403 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
opentaskspal/src/main/java/org/dmfs/opentaskspal/operations/SubtaskRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.operations; | ||
|
||
import android.content.ContentProviderOperation; | ||
import android.support.annotation.NonNull; | ||
|
||
import org.dmfs.android.contentpal.InsertOperation; | ||
import org.dmfs.android.contentpal.Operation; | ||
import org.dmfs.android.contentpal.RowSnapshot; | ||
import org.dmfs.android.contentpal.SoftRowReference; | ||
import org.dmfs.android.contentpal.TransactionContext; | ||
import org.dmfs.android.contentpal.operations.Insert; | ||
import org.dmfs.opentaskspal.tables.PropertiesTable; | ||
import org.dmfs.opentaskspal.tasks.ParentTaskRelationData; | ||
import org.dmfs.optional.Optional; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link InsertOperation} for adding a 'subtask relation' property to {@link TaskContract.Properties} table. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class SubtaskRelation implements InsertOperation<TaskContract.Properties> | ||
{ | ||
|
||
private final Operation<TaskContract.Properties> mDelegate; | ||
|
||
|
||
public SubtaskRelation(String authority, RowSnapshot<TaskContract.Tasks> subtask, RowSnapshot<TaskContract.Tasks> parentTask) | ||
{ | ||
mDelegate = new Insert<>(new PropertiesTable(authority), new ParentTaskRelationData(parentTask, subtask)); | ||
} | ||
|
||
|
||
@NonNull | ||
@Override | ||
public Optional<SoftRowReference<TaskContract.Properties>> reference() | ||
{ | ||
return mDelegate.reference(); | ||
} | ||
|
||
|
||
@NonNull | ||
@Override | ||
public ContentProviderOperation.Builder contentOperationBuilder(@NonNull TransactionContext transactionContext) throws UnsupportedOperationException | ||
{ | ||
return mDelegate.contentOperationBuilder(transactionContext); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
opentaskspal/src/main/java/org/dmfs/opentaskspal/predicates/IsProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.predicates; | ||
|
||
import org.dmfs.android.contentpal.Predicate; | ||
import org.dmfs.android.contentpal.predicates.DelegatingPredicate; | ||
import org.dmfs.android.contentpal.predicates.EqArg; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link Predicate} for selecting rows from {@link TaskContract.Properties} table representing a certain property identified by its mimeType. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class IsProperty extends DelegatingPredicate | ||
{ | ||
public IsProperty(String mimeType) | ||
{ | ||
super(new EqArg(TaskContract.PropertyColumns.MIMETYPE, mimeType)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
opentaskspal/src/main/java/org/dmfs/opentaskspal/predicates/IsRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.predicates; | ||
|
||
import org.dmfs.android.contentpal.Predicate; | ||
import org.dmfs.android.contentpal.predicates.DelegatingPredicate; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link Predicate} for selecting {@link TaskContract.Property.Relation} properties from {@link TaskContract.Properties} table. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class IsRelation extends DelegatingPredicate | ||
{ | ||
public IsRelation() | ||
{ | ||
super(new IsProperty(TaskContract.Property.Relation.CONTENT_ITEM_TYPE)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
opentaskspal/src/main/java/org/dmfs/opentaskspal/rowsets/Subtasks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.rowsets; | ||
|
||
import android.content.ContentProviderClient; | ||
import android.support.annotation.NonNull; | ||
|
||
import org.dmfs.android.contentpal.RowSet; | ||
import org.dmfs.android.contentpal.RowSnapshot; | ||
import org.dmfs.android.contentpal.predicates.ReferringTo; | ||
import org.dmfs.android.contentpal.rowsets.DelegatingRowSet; | ||
import org.dmfs.android.contentpal.rowsets.QueryRowSet; | ||
import org.dmfs.opentaskspal.views.TasksView; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link RowSet} for the subtasks of a given task. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class Subtasks extends DelegatingRowSet<TaskContract.Tasks> | ||
{ | ||
|
||
public Subtasks(String authority, ContentProviderClient client, @NonNull RowSnapshot<TaskContract.Tasks> parentTask) | ||
{ | ||
super(new QueryRowSet<>(new TasksView(authority, client), new ReferringTo<>(TaskContract.Tasks.PARENT_ID, parentTask))); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
opentaskspal/src/main/java/org/dmfs/opentaskspal/tables/PropertiesTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.tables; | ||
|
||
import org.dmfs.android.contentpal.Table; | ||
import org.dmfs.android.contentpal.tables.BaseTable; | ||
import org.dmfs.android.contentpal.tables.DelegatingTable; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link Table} for {@link TaskContract.Properties}. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class PropertiesTable extends DelegatingTable<TaskContract.Properties> | ||
{ | ||
public PropertiesTable(String authority) | ||
{ | ||
super(new BaseTable<TaskContract.Properties>(TaskContract.Properties.getContentUri(authority))); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/ChildTaskRelationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.tasks; | ||
|
||
import org.dmfs.android.contentpal.RowData; | ||
import org.dmfs.android.contentpal.RowSnapshot; | ||
import org.dmfs.android.contentpal.rowdata.DelegatingRowData; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
import org.dmfs.tasks.contract.TaskContract.Property.Relation.RelType; | ||
|
||
|
||
/** | ||
* {@link RowData} to add the {@link RelType#CHILD} relation between the 2 given tasks, to the {@link TaskContract.Properties} table. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class ChildTaskRelationData extends DelegatingRowData<TaskContract.Properties> | ||
{ | ||
public ChildTaskRelationData(RowSnapshot<TaskContract.Tasks> childTask, RowSnapshot<TaskContract.Tasks> parentTask) | ||
{ | ||
super(new RelationData(parentTask, RelType.CHILD, childTask)); | ||
} | ||
|
||
|
||
public ChildTaskRelationData(CharSequence childTaskUid, RowSnapshot<TaskContract.Tasks> parentTask) | ||
{ | ||
super(new RelationData(parentTask, RelType.CHILD, childTaskUid)); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/ParentTaskRelationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.tasks; | ||
|
||
import org.dmfs.android.contentpal.RowData; | ||
import org.dmfs.android.contentpal.RowSnapshot; | ||
import org.dmfs.android.contentpal.rowdata.DelegatingRowData; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
import org.dmfs.tasks.contract.TaskContract.Property.Relation.RelType; | ||
|
||
|
||
/** | ||
* {@link RowData} to add the {@link RelType#PARENT} relation between the 2 given tasks, to the {@link TaskContract.Properties} table. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class ParentTaskRelationData extends DelegatingRowData<TaskContract.Properties> | ||
{ | ||
public ParentTaskRelationData(RowSnapshot<TaskContract.Tasks> parentTask, RowSnapshot<TaskContract.Tasks> childTask) | ||
{ | ||
super(new RelationData(childTask, RelType.PARENT, parentTask)); | ||
} | ||
|
||
public ParentTaskRelationData(CharSequence parentTaskUid, RowSnapshot<TaskContract.Tasks> childTask) | ||
{ | ||
super(new RelationData(childTask, RelType.PARENT, parentTaskUid)); | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
opentaskspal/src/main/java/org/dmfs/opentaskspal/tasks/RelationData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2017 dmfs GmbH | ||
* | ||
* 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.dmfs.opentaskspal.tasks; | ||
|
||
import android.support.annotation.NonNull; | ||
|
||
import org.dmfs.android.contentpal.RowData; | ||
import org.dmfs.android.contentpal.RowSnapshot; | ||
import org.dmfs.android.contentpal.rowdata.CharSequenceRowData; | ||
import org.dmfs.android.contentpal.rowdata.Composite; | ||
import org.dmfs.android.contentpal.rowdata.DelegatingRowData; | ||
import org.dmfs.android.contentpal.rowdata.RawRowData; | ||
import org.dmfs.android.contentpal.rowdata.Referring; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
import org.dmfs.tasks.contract.TaskContract.Property.Relation.RelType; | ||
|
||
|
||
/** | ||
* {@link RowData} for adding a {@link TaskContract.Property.Relation} property. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class RelationData extends DelegatingRowData<TaskContract.Properties> | ||
{ | ||
public RelationData(@NonNull RowSnapshot<TaskContract.Tasks> relatingTask, | ||
@NonNull RelType relType, | ||
@NonNull RowSnapshot<TaskContract.Tasks> relatedTask) | ||
{ | ||
super(new Composite<>( | ||
new Referring<TaskContract.Properties>(TaskContract.Property.Relation.TASK_ID, relatingTask), | ||
new RawRowData<TaskContract.Properties>(TaskContract.Property.Relation.RELATED_TYPE, relType.ordinal()), | ||
new Referring<TaskContract.Properties>(TaskContract.Property.Relation.RELATED_ID, relatedTask))); | ||
} | ||
|
||
|
||
public RelationData(@NonNull RowSnapshot<TaskContract.Tasks> relatingTask, | ||
@NonNull RelType relType, | ||
@NonNull CharSequence relatedTaskUid) | ||
{ | ||
super(new Composite<>( | ||
new Referring<TaskContract.Properties>(TaskContract.Property.Relation.TASK_ID, relatingTask), | ||
new RawRowData<TaskContract.Properties>(TaskContract.Property.Relation.RELATED_TYPE, relType.ordinal()), | ||
new CharSequenceRowData<TaskContract.Properties>(TaskContract.Property.Relation.RELATED_UID, relatedTaskUid))); | ||
} | ||
} |
Oops, something went wrong.