#AMB-36 -> entities, repositories and fetchApis...

This commit is contained in:
reinjens 2024-10-29 16:15:11 +01:00
parent c4174a248d
commit 4aa60980a1
72 changed files with 29111 additions and 201 deletions

2
.env
View file

@ -1,2 +1,2 @@
BASEROW_TOKEN="TFxO7vzBLVRCu9I3VMoHmTuCvSu8aCDi"
BASEROW_IDS='{"measure": 328253, "measure_combination": 328217, "organism": 328255, "funding_program": 328256, "factsheet": 328273, "standortansprueche": 328188, "referenzumsetzung": 328465, "betriebsverzeichnis": 328472, "erfahrungsbericht": 330802, "genehmigungspflicht": 330806, "dienstleister": 330824, "ansprechperson": 330832, "material": 330836, "quellen": 334231, "tree_type": 342622, "aenderungfactsheet": 330946}'
BASEROW_IDS='{"measure": 328253,"measure_combination": 328217, "organism": 328255, "funding_program": 328256, "factsheet": 328273, "location_requirements": 328188, "reference_implementation": 328465, "business": 328472, "experience_report": 330802, "approval_requirement": 330806, "service_provider": 330824, "service_provider_contact_person": 330832, "material": 330836, "source": 334231, "tree_type": 342622, "aenderungfactsheet": 330946}'

View file

@ -1,6 +1,5 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/domain/entity/funding_program/funding_program.dart';
import 'package:ambito/src/packages/ambito_api/base.dart';
import 'package:ambito/src/packages/ambito_api/base_api.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:ambito/src/pages/loading/loading_page.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -20,31 +19,23 @@ late Isar isar;
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: '.env');
await Isar.initialize();
const dir = Isar.sqliteInMemory;
const engine = kIsWeb ? IsarEngine.sqlite : IsarEngine.isar;
isar = Isar.open(
schemas: [
FundingProgramSchema,
MeasureSchema,
MeasureCombinationSchema,
OrganismSchema,
TreeTypeSchema,
],
directory: dir,
engine: engine,
inspector: true,
);
await AmbitoIsarDB().init();
await Future.wait([
BaseApi().getContent('tree_type'),
/*BaseApi().getContent('tree_type'),
BaseApi().getContent('measure'),
BaseApi().getContent('measure_combination'),
BaseApi().getContent('organism'),
BaseApi().getContent('funding_program'),
BaseApi().getContent('location_requirements'),
BaseApi().getContent('reference_implementation'),
BaseApi().getContent('business'),
BaseApi().getContent('service_provider'),
BaseApi().getContent('service_provider_contact_person'),
BaseApi().getContent('material'),*/
BaseApi().getContent('source'),
]);
runApp(const Ambito());

View file

@ -1,14 +0,0 @@
library ambito_entities;
export 'base_entity.dart';
export 'general/file/file_part.dart';
export 'general/file/thumbnail.dart';
export 'general/file/thumbnails.dart';
export 'general/id_value/id_value.dart';
export 'general/id_value_color/id_value_color.dart';
export 'general/id_value_mix/id_value_mix.dart';
export 'general/month/month.dart';
export 'measure/measure.dart';
export 'measure_combination/measure_combination.dart';
export 'organism/organism.dart';
export 'tree_type//tree_type.dart';

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -0,0 +1,30 @@
import 'package:ambito/src/entity/_general/id_value/id_value.dart';
import 'package:ambito/src/entity/_general/id_value_color/id_value_color.dart';
import 'package:ambito/src/entity/base_entity.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'approval_requirement.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class ApprovalRequirement extends BaseEntity with EntityWithId {
ApprovalRequirement();
@JsonKey(name: 'Name der Genehmigung')
@Index()
String? name;
@JsonKey(name: 'Anmerkungen')
String? notes;
@JsonKey(name: 'Maßnahme')
List<IdValue>? measures;
@JsonKey(name: 'Behörde')
List<IdValueColor>? authority;
@JsonKey(name: 'Art der Genehmigung')
List<IdValueColor>? typeOfApproval;
factory ApprovalRequirement.fromJson(Map<String, dynamic> json) =>
_$ApprovalRequirementFromJson(json);
Map<String, dynamic> toJson() => _$ApprovalRequirementToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class ApprovalRequirementRepository extends BaseDB {
@override
IsarCollection collection = isar.approvalRequirements;
}

View file

@ -0,0 +1,73 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'business.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class Business extends BaseEntity with EntityWithId {
Business();
@JsonKey(name: 'Modellbetrieb')
@Index()
String? name;
@JsonKey(name: 'Ursprungsgebiet')
IdValueColor? areaOfOrigin;
@JsonKey(name: 'Ansprechpartner')
String? businessOwner;
@JsonKey(name: 'Feld 6')
String? businessEmail;
@JsonKey(name: 'Feld 7')
String? businessPhone;
@JsonKey(name: 'Feld 8')
String? contactName;
@JsonKey(name: 'Feld 9')
String? contactPosition;
@JsonKey(name: 'Feld 10')
String? contactEmail;
@JsonKey(name: 'Feld 11')
String? contactPhone;
@JsonKey(name: 'Feld 12')
String? contact2Name;
@JsonKey(name: 'Feld 13')
String? contact2Position;
@JsonKey(name: 'Feld 14')
String? contact2Email;
@JsonKey(name: 'Feld 15')
String? contact2Phone;
@JsonKey(name: 'Feld 16')
String? contact3Name;
@JsonKey(name: 'Feld 17')
String? contact3Email;
@JsonKey(name: 'Feld 18')
String? addressComplete;
@JsonKey(name: 'Feld 19')
String? addressStreet;
@JsonKey(name: 'Feld 20')
String? addressPostalCode;
@JsonKey(name: 'Feld 21')
String? addressCity;
@JsonKey(name: 'Feld 22')
String? addressRegion;
@JsonKey(name: 'Feld 23')
String? addressFederalState;
@JsonKey(name: 'Feld 24')
String? unknown;
@JsonKey(name: 'Feld 25')
String? businessType;
@JsonKey(name: 'Region')
String? region;
@JsonKey(name: 'Umgesetze_Maßnahmen')
List<IdValueColor>? measures;
@JsonKey(name: '05 Referenzumsetzung')
List<IdValueColor>? referenceImplementation;
@JsonKey(name: '07 Erfahrungsbericht Umsetuzung')
List<IdValueColor>? experienceReport;
factory Business.fromJson(Map<String, dynamic> json) =>
_$BusinessFromJson(json);
Map<String, dynamic> toJson() => _$BusinessToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class BusinessRepository extends BaseDB {
@override
IsarCollection collection = isar.business;
}

View file

@ -0,0 +1,25 @@
library ambito_entities;
export '_general/file/file_part.dart';
export '_general/file/thumbnail.dart';
export '_general/file/thumbnails.dart';
export '_general/id_value/id_value.dart';
export '_general/id_value_color/id_value_color.dart';
export '_general/id_value_mix/id_value_mix.dart';
export '_general/month/month.dart';
export 'approval_requirement/approval_requirement.dart';
export 'base_entity.dart';
export 'business/business.dart';
export 'experience_report/experience_report.dart';
export 'funding_program/funding_program.dart';
export 'location_requirements/location_requirements.dart';
export 'material/material.dart';
export 'measure/measure.dart';
export 'measure_combination/measure_combination.dart';
export 'number_factsheet/number_factsheet.dart';
export 'organism/organism.dart';
export 'reference_implementation/reference_implementation.dart';
export 'service_provider/service_provider.dart';
export 'service_provider/service_provider_contact_person.dart';
export 'source/source.dart';
export 'tree_type/tree_type.dart';

View file

@ -0,0 +1,25 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'experience_report.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class ExperienceReport extends BaseEntity with EntityWithId {
ExperienceReport();
@JsonKey(name: 'Kurztitel')
String? title;
@JsonKey(name: 'Ausführlicher Refahrungsbericht')
String? content;
@JsonKey(name: 'Maßnahme')
List<IdValue>? measures;
@JsonKey(name: 'Betrieb')
List<IdValue>? business;
factory ExperienceReport.fromJson(Map<String, dynamic> json) =>
_$ExperienceReportFromJson(json);
Map<String, dynamic> toJson() => _$ExperienceReportToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class ExperienceReportRepository extends BaseDB {
@override
IsarCollection collection = isar.experienceReports;
}

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/funding_program/funding_program.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class FundingProgramRepository extends BaseDB {
@override
IsarCollection collection = isar.fundingPrograms;
}

View file

@ -0,0 +1,43 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'location_requirements.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class LocationRequirements extends BaseEntity with EntityWithIdAndName {
LocationRequirements();
@JsonKey(name: 'Maßnahmentabelle Standortansprüche')
List<IdValue>? measures;
@JsonKey(name: 'Flächentyp')
List<IdValueColor>? areaType;
@JsonKey(name: 'Exposition')
List<IdValueColor>? exposition;
@JsonKey(name: 'Licht')
List<IdValueColor>? light;
@JsonKey(name: 'Feuchtigkeit')
List<IdValueColor>? humidity;
@JsonKey(name: 'Topographie')
List<IdValueColor>? topography;
@JsonKey(name: 'Geometrie')
List<IdValueColor>? geometry;
@JsonKey(name: 'Wertigkeit')
IdValueColor? value;
@JsonKey(name: 'Kosten')
IdValueColor? costs;
@JsonKey(name: 'Aufwand')
IdValueColor? effort;
@JsonKey(name: 'Pflegeaufwand')
IdValueColor? careEffort;
@JsonKey(name: 'Mindesflächengröße in m²')
int? minimalAreaSize;
@JsonKey(name: 'Boden')
List<IdValueColor>? ground;
factory LocationRequirements.fromJson(Map<String, dynamic> json) =>
_$LocationRequirementsFromJson(json);
Map<String, dynamic> toJson() => _$LocationRequirementsToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class LocationRequirementsRepository extends BaseDB {
@override
IsarCollection collection = isar.locationRequirements;
}

View file

@ -0,0 +1,24 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'material.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class Material extends BaseEntity with EntityWithId {
Material();
@JsonKey(name: 'Name Material')
@Index(unique: true, hash: true)
String? name;
@JsonKey(name: 'Bezugsquelle')
List<IdValueColor>? sourceOfSupply;
@JsonKey(name: 'Durchschnittlicher Preis')
double? averagePrice;
factory Material.fromJson(Map<String, dynamic> json) =>
_$MaterialFromJson(json);
Map<String, dynamic> toJson() => _$MaterialToJson(this);
}

View file

@ -0,0 +1,917 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'material.dart';
// **************************************************************************
// _IsarCollectionGenerator
// **************************************************************************
// coverage:ignore-file
// ignore_for_file: duplicate_ignore, invalid_use_of_protected_member, lines_longer_than_80_chars, constant_identifier_names, avoid_js_rounded_ints, no_leading_underscores_for_local_identifiers, require_trailing_commas, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_in_if_null_operators, library_private_types_in_public_api, prefer_const_constructors
// ignore_for_file: type=lint
extension GetMaterialCollection on Isar {
IsarCollection<int, Material> get materials => this.collection();
}
const MaterialSchema = IsarGeneratedSchema(
schema: IsarSchema(
name: 'Material',
idName: 'id',
embedded: false,
properties: [
IsarPropertySchema(
name: 'name',
type: IsarType.string,
),
IsarPropertySchema(
name: 'sourceOfSupply',
type: IsarType.objectList,
target: 'IdValueColor',
),
IsarPropertySchema(
name: 'averagePrice',
type: IsarType.double,
),
],
indexes: [
IsarIndexSchema(
name: 'name',
properties: [
"name",
],
unique: true,
hash: true,
),
],
),
converter: IsarObjectConverter<int, Material>(
serialize: serializeMaterial,
deserialize: deserializeMaterial,
deserializeProperty: deserializeMaterialProp,
),
embeddedSchemas: [IdValueColorSchema],
);
@isarProtected
int serializeMaterial(IsarWriter writer, Material object) {
{
final value = object.name;
if (value == null) {
IsarCore.writeNull(writer, 1);
} else {
IsarCore.writeString(writer, 1, value);
}
}
{
final list = object.sourceOfSupply;
if (list == null) {
IsarCore.writeNull(writer, 2);
} else {
final listWriter = IsarCore.beginList(writer, 2, list.length);
for (var i = 0; i < list.length; i++) {
{
final value = list[i];
final objectWriter = IsarCore.beginObject(listWriter, i);
serializeIdValueColor(objectWriter, value);
IsarCore.endObject(listWriter, objectWriter);
}
}
IsarCore.endList(writer, listWriter);
}
}
IsarCore.writeDouble(writer, 3, object.averagePrice ?? double.nan);
return object.id;
}
@isarProtected
Material deserializeMaterial(IsarReader reader) {
final object = Material();
object.name = IsarCore.readString(reader, 1);
{
final length = IsarCore.readList(reader, 2, IsarCore.readerPtrPtr);
{
final reader = IsarCore.readerPtr;
if (reader.isNull) {
object.sourceOfSupply = null;
} else {
final list =
List<IdValueColor>.filled(length, IdValueColor(), growable: true);
for (var i = 0; i < length; i++) {
{
final objectReader = IsarCore.readObject(reader, i);
if (objectReader.isNull) {
list[i] = IdValueColor();
} else {
final embedded = deserializeIdValueColor(objectReader);
IsarCore.freeReader(objectReader);
list[i] = embedded;
}
}
}
IsarCore.freeReader(reader);
object.sourceOfSupply = list;
}
}
}
{
final value = IsarCore.readDouble(reader, 3);
if (value.isNaN) {
object.averagePrice = null;
} else {
object.averagePrice = value;
}
}
object.id = IsarCore.readId(reader);
return object;
}
@isarProtected
dynamic deserializeMaterialProp(IsarReader reader, int property) {
switch (property) {
case 1:
return IsarCore.readString(reader, 1);
case 2:
{
final length = IsarCore.readList(reader, 2, IsarCore.readerPtrPtr);
{
final reader = IsarCore.readerPtr;
if (reader.isNull) {
return null;
} else {
final list = List<IdValueColor>.filled(length, IdValueColor(),
growable: true);
for (var i = 0; i < length; i++) {
{
final objectReader = IsarCore.readObject(reader, i);
if (objectReader.isNull) {
list[i] = IdValueColor();
} else {
final embedded = deserializeIdValueColor(objectReader);
IsarCore.freeReader(objectReader);
list[i] = embedded;
}
}
}
IsarCore.freeReader(reader);
return list;
}
}
}
case 3:
{
final value = IsarCore.readDouble(reader, 3);
if (value.isNaN) {
return null;
} else {
return value;
}
}
case 0:
return IsarCore.readId(reader);
default:
throw ArgumentError('Unknown property: $property');
}
}
sealed class _MaterialUpdate {
bool call({
required int id,
String? name,
double? averagePrice,
});
}
class _MaterialUpdateImpl implements _MaterialUpdate {
const _MaterialUpdateImpl(this.collection);
final IsarCollection<int, Material> collection;
@override
bool call({
required int id,
Object? name = ignore,
Object? averagePrice = ignore,
}) {
return collection.updateProperties([
id
], {
if (name != ignore) 1: name as String?,
if (averagePrice != ignore) 3: averagePrice as double?,
}) >
0;
}
}
sealed class _MaterialUpdateAll {
int call({
required List<int> id,
String? name,
double? averagePrice,
});
}
class _MaterialUpdateAllImpl implements _MaterialUpdateAll {
const _MaterialUpdateAllImpl(this.collection);
final IsarCollection<int, Material> collection;
@override
int call({
required List<int> id,
Object? name = ignore,
Object? averagePrice = ignore,
}) {
return collection.updateProperties(id, {
if (name != ignore) 1: name as String?,
if (averagePrice != ignore) 3: averagePrice as double?,
});
}
}
extension MaterialUpdate on IsarCollection<int, Material> {
_MaterialUpdate get update => _MaterialUpdateImpl(this);
_MaterialUpdateAll get updateAll => _MaterialUpdateAllImpl(this);
}
sealed class _MaterialQueryUpdate {
int call({
String? name,
double? averagePrice,
});
}
class _MaterialQueryUpdateImpl implements _MaterialQueryUpdate {
const _MaterialQueryUpdateImpl(this.query, {this.limit});
final IsarQuery<Material> query;
final int? limit;
@override
int call({
Object? name = ignore,
Object? averagePrice = ignore,
}) {
return query.updateProperties(limit: limit, {
if (name != ignore) 1: name as String?,
if (averagePrice != ignore) 3: averagePrice as double?,
});
}
}
extension MaterialQueryUpdate on IsarQuery<Material> {
_MaterialQueryUpdate get updateFirst =>
_MaterialQueryUpdateImpl(this, limit: 1);
_MaterialQueryUpdate get updateAll => _MaterialQueryUpdateImpl(this);
}
class _MaterialQueryBuilderUpdateImpl implements _MaterialQueryUpdate {
const _MaterialQueryBuilderUpdateImpl(this.query, {this.limit});
final QueryBuilder<Material, Material, QOperations> query;
final int? limit;
@override
int call({
Object? name = ignore,
Object? averagePrice = ignore,
}) {
final q = query.build();
try {
return q.updateProperties(limit: limit, {
if (name != ignore) 1: name as String?,
if (averagePrice != ignore) 3: averagePrice as double?,
});
} finally {
q.close();
}
}
}
extension MaterialQueryBuilderUpdate
on QueryBuilder<Material, Material, QOperations> {
_MaterialQueryUpdate get updateFirst =>
_MaterialQueryBuilderUpdateImpl(this, limit: 1);
_MaterialQueryUpdate get updateAll => _MaterialQueryBuilderUpdateImpl(this);
}
extension MaterialQueryFilter
on QueryBuilder<Material, Material, QFilterCondition> {
QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const IsNullCondition(property: 1));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNotNull() {
return QueryBuilder.apply(not(), (query) {
return query.addFilterCondition(const IsNullCondition(property: 1));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameGreaterThan(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
nameGreaterThanOrEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameLessThan(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameLessThanOrEqualTo(
String? value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameBetween(
String? lower,
String? upper, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 1,
lower: lower,
upper: upper,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameStartsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
StartsWithCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameEndsWith(
String value, {
bool caseSensitive = true,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EndsWithCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameContains(
String value,
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
ContainsCondition(
property: 1,
value: value,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameMatches(
String pattern,
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
MatchesCondition(
property: 1,
wildcard: pattern,
caseSensitive: caseSensitive,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameIsEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
const EqualCondition(
property: 1,
value: '',
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> nameIsNotEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
const GreaterCondition(
property: 1,
value: '',
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
sourceOfSupplyIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const IsNullCondition(property: 2));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
sourceOfSupplyIsNotNull() {
return QueryBuilder.apply(not(), (query) {
return query.addFilterCondition(const IsNullCondition(property: 2));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
sourceOfSupplyIsEmpty() {
return not().group(
(q) => q.sourceOfSupplyIsNull().or().sourceOfSupplyIsNotEmpty(),
);
}
QueryBuilder<Material, Material, QAfterFilterCondition>
sourceOfSupplyIsNotEmpty() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
const GreaterOrEqualCondition(property: 2, value: null),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const IsNullCondition(property: 3));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
averagePriceIsNotNull() {
return QueryBuilder.apply(not(), (query) {
return query.addFilterCondition(const IsNullCondition(property: 3));
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceEqualTo(
double? value, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 3,
value: value,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
averagePriceGreaterThan(
double? value, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 3,
value: value,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
averagePriceGreaterThanOrEqualTo(
double? value, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 3,
value: value,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceLessThan(
double? value, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 3,
value: value,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
averagePriceLessThanOrEqualTo(
double? value, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 3,
value: value,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> averagePriceBetween(
double? lower,
double? upper, {
double epsilon = Filter.epsilon,
}) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 3,
lower: lower,
upper: upper,
epsilon: epsilon,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> idEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
EqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> idGreaterThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition>
idGreaterThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
GreaterOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> idLessThan(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> idLessThanOrEqualTo(
int value,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
LessOrEqualCondition(
property: 0,
value: value,
),
);
});
}
QueryBuilder<Material, Material, QAfterFilterCondition> idBetween(
int lower,
int upper,
) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(
BetweenCondition(
property: 0,
lower: lower,
upper: upper,
),
);
});
}
}
extension MaterialQueryObject
on QueryBuilder<Material, Material, QFilterCondition> {}
extension MaterialQuerySortBy on QueryBuilder<Material, Material, QSortBy> {
QueryBuilder<Material, Material, QAfterSortBy> sortByName(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(
1,
caseSensitive: caseSensitive,
);
});
}
QueryBuilder<Material, Material, QAfterSortBy> sortByNameDesc(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(
1,
sort: Sort.desc,
caseSensitive: caseSensitive,
);
});
}
QueryBuilder<Material, Material, QAfterSortBy> sortByAveragePrice() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(3);
});
}
QueryBuilder<Material, Material, QAfterSortBy> sortByAveragePriceDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(3, sort: Sort.desc);
});
}
QueryBuilder<Material, Material, QAfterSortBy> sortById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Material, Material, QAfterSortBy> sortByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension MaterialQuerySortThenBy
on QueryBuilder<Material, Material, QSortThenBy> {
QueryBuilder<Material, Material, QAfterSortBy> thenByName(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(1, caseSensitive: caseSensitive);
});
}
QueryBuilder<Material, Material, QAfterSortBy> thenByNameDesc(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(1, sort: Sort.desc, caseSensitive: caseSensitive);
});
}
QueryBuilder<Material, Material, QAfterSortBy> thenByAveragePrice() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(3);
});
}
QueryBuilder<Material, Material, QAfterSortBy> thenByAveragePriceDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(3, sort: Sort.desc);
});
}
QueryBuilder<Material, Material, QAfterSortBy> thenById() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0);
});
}
QueryBuilder<Material, Material, QAfterSortBy> thenByIdDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(0, sort: Sort.desc);
});
}
}
extension MaterialQueryWhereDistinct
on QueryBuilder<Material, Material, QDistinct> {
QueryBuilder<Material, Material, QAfterDistinct> distinctByName(
{bool caseSensitive = true}) {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(1, caseSensitive: caseSensitive);
});
}
QueryBuilder<Material, Material, QAfterDistinct> distinctByAveragePrice() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(3);
});
}
}
extension MaterialQueryProperty1
on QueryBuilder<Material, Material, QProperty> {
QueryBuilder<Material, String?, QAfterProperty> nameProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
});
}
QueryBuilder<Material, List<IdValueColor>?, QAfterProperty>
sourceOfSupplyProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(2);
});
}
QueryBuilder<Material, double?, QAfterProperty> averagePriceProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(3);
});
}
QueryBuilder<Material, int, QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension MaterialQueryProperty2<R>
on QueryBuilder<Material, R, QAfterProperty> {
QueryBuilder<Material, (R, String?), QAfterProperty> nameProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
});
}
QueryBuilder<Material, (R, List<IdValueColor>?), QAfterProperty>
sourceOfSupplyProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(2);
});
}
QueryBuilder<Material, (R, double?), QAfterProperty> averagePriceProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(3);
});
}
QueryBuilder<Material, (R, int), QAfterProperty> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
extension MaterialQueryProperty3<R1, R2>
on QueryBuilder<Material, (R1, R2), QAfterProperty> {
QueryBuilder<Material, (R1, R2, String?), QOperations> nameProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(1);
});
}
QueryBuilder<Material, (R1, R2, List<IdValueColor>?), QOperations>
sourceOfSupplyProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(2);
});
}
QueryBuilder<Material, (R1, R2, double?), QOperations>
averagePriceProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(3);
});
}
QueryBuilder<Material, (R1, R2, int), QOperations> idProperty() {
return QueryBuilder.apply(this, (query) {
return query.addProperty(0);
});
}
}
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
Material _$MaterialFromJson(Map<String, dynamic> json) => Material()
..id = (json['id'] as num).toInt()
..name = json['Name Material'] as String?
..sourceOfSupply = (json['Bezugsquelle'] as List<dynamic>?)
?.map((e) => IdValueColor.fromJson(e as Map<String, dynamic>))
.toList()
..averagePrice = (json['Durchschnittlicher Preis'] as num?)?.toDouble();
Map<String, dynamic> _$MaterialToJson(Material instance) => <String, dynamic>{
'id': instance.id,
'Name Material': instance.name,
'Bezugsquelle': instance.sourceOfSupply?.map((e) => e.toJson()).toList(),
'Durchschnittlicher Preis': instance.averagePrice,
};

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class MaterialRepository extends BaseDB {
@override
IsarCollection collection = isar.materials;
}

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class MeasureRepository extends BaseDB {
@override
IsarCollection collection = isar.measures;
}

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class MeasureCombinationRepository extends BaseDB {
@override
IsarCollection collection = isar.measureCombinations;
}

View file

@ -0,0 +1,30 @@
import 'package:ambito/src/entity/base_entity.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'number_factsheet.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class NumberFactsheet extends BaseEntity with EntityWithId {
NumberFactsheet();
@JsonKey(name: 'Einzelmaßnahme(3. Ebene)')
@Index(unique: true, hash: true)
String? singleMeasure;
@JsonKey(name: '00 Maßnahmen_Main')
@Index()
String? measure;
@JsonKey(name: 'Formel')
String? formula;
@JsonKey(name: 'versandfertig als PDF abgelegt')
String? readyPDF;
@JsonKey(name: 'Nr.')
String? number;
@JsonKey(name: 'Priorität')
String? priority;
@JsonKey(
name:
'Maßnahmendatenblatt Qualitätskontrolle vollständig und ok (KM) (2402610)')
String? qmPassed;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class NumberFactsheetRepository extends BaseDB {
@override
IsarCollection collection = isar.numberFactsheets;
}

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class OrganismRepository extends BaseDB {
@override
IsarCollection collection = isar.organisms;
}

View file

@ -0,0 +1,65 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'reference_implementation.g.dart';
@JsonSerializable()
@collection
class ReferenceImplementation extends BaseEntity with EntityWithId {
ReferenceImplementation();
@JsonKey(name: 'Liste aller Maßnahmen')
@Index()
String? listOfMeasures;
@JsonKey(name: 'Datum der Anlage')
String? dateStart;
@JsonKey(name: '06 Betriebsverzeichnis')
List<IdValue>? businessDirectory;
@JsonKey(name: '00 Maßnahmendatenbank')
List<IdValue>? measures;
@JsonKey(name: 'Größe in m²')
int? areaSize;
@JsonKey(name: 'Beschreibung')
String? description;
@JsonKey(name: 'Fotos')
List<FilePart> images = [];
@JsonKey(name: 'Gesamtkosten')
String? costsTotal;
@JsonKey(name: 'Link zum Geomarker')
String? linkToGeo;
@JsonKey(name: 'Status')
IdValueColor? status;
@JsonKey(name: 'Materialbezug ohne AmBiTo')
bool externalOrder = false;
@JsonKey(name: 'Anzahl Elemente')
String? elementCount;
@JsonKey(name: 'Bestellwert')
String? orderValue;
@JsonKey(name: 'Lieferung')
String? shippingCosts;
@JsonKey(name: 'Anlage')
String? constructionCosts;
@JsonKey(name: 'Sträucher Kosten')
String? shrubsCosts;
@JsonKey(name: 'Bäume Kosten')
String? treeCosts;
@JsonKey(name: 'Sträucher Pflanzkosten')
String? shrubsPlantingCosts;
@JsonKey(name: 'Bäume Pflanzkosten')
String? treePlantingCosts;
@JsonKey(name: 'Anzahl Sträucher')
String? shrubsCount;
@JsonKey(name: 'Anzahl Bäume')
String? treeCount;
@JsonKey(name: 'Anmerkung')
String? note;
@JsonKey(name: 'Bearbeitet von')
IdValue? editedBy;
factory ReferenceImplementation.fromJson(Map<String, dynamic> json) =>
_$ReferenceImplementationFromJson(json);
Map<String, dynamic> toJson() => _$ReferenceImplementationToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class ReferenceImplementationRepository extends BaseDB {
@override
IsarCollection collection = isar.referenceImplementations;
}

View file

@ -0,0 +1,40 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'service_provider.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class ServiceProvider extends BaseEntity with EntityWithId {
ServiceProvider();
@JsonKey(name: 'Name des Dienstleisters')
@Index()
String? name;
@JsonKey(name: 'Link Webseite')
String? website;
@JsonKey(name: 'Postleitzahl und Ort')
String? postalCodeAndCity;
@JsonKey(name: 'Telefonnummer')
String? phoneNumber;
@JsonKey(name: 'E-Mail')
String? email;
@JsonKey(name: 'Ansprechpersonen')
List<IdValue>? contactPerson;
@JsonKey(name: '00 Maßnahmen_Main')
List<IdValue>? measures;
@JsonKey(name: 'Straße und Hausnummer')
String? streetAddress;
@JsonKey(name: 'Region')
List<IdValueColor>? region;
@JsonKey(name: 'Art des Unternehmens')
List<IdValueColor>? businessType;
@JsonKey(name: 'Bio-zertifiziert?')
bool certifiedBio = false;
factory ServiceProvider.fromJson(Map<String, dynamic> json) =>
_$ServiceProviderFromJson(json);
Map<String, dynamic> toJson() => _$ServiceProviderToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,27 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'service_provider_contact_person.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class ServiceProviderContactPerson extends BaseEntity with EntityWithIdAndName {
ServiceProviderContactPerson();
@JsonKey(name: 'E-Mail')
String? email;
@JsonKey(name: 'Telefonnummer')
String? phoneNumber;
@JsonKey(name: 'Kurzbeschreibung')
String? description;
@JsonKey(name: '09 Dienstleister')
List<IdValue>? serviceProvider;
@JsonKey(name: '00 Maßnahmen_Main')
List<IdValue>? measures;
factory ServiceProviderContactPerson.fromJson(Map<String, dynamic> json) =>
_$ServiceProviderContactPersonFromJson(json);
Map<String, dynamic> toJson() => _$ServiceProviderContactPersonToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class ServiceProviderContactPersonRepository extends BaseDB {
@override
IsarCollection collection = isar.serviceProviderContactPersons;
}

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class ServiceProviderRepository extends BaseDB {
@override
IsarCollection collection = isar.serviceProviders;
}

View file

@ -0,0 +1,43 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';
part 'source.g.dart';
@JsonSerializable(explicitToJson: true)
@collection
class Source extends BaseEntity with EntityWithId {
Source();
@JsonKey(name: 'Titel')
@Index()
String? title;
@JsonKey(name: '00 Maßnahmen_Main')
List<IdValue>? measures;
@JsonKey(name: 'Tag')
List<IdValueColor>? tags;
@JsonKey(name: 'Erscheinungsjahr')
String? publicationYear;
@JsonKey(name: 'Link Webseite')
String? url;
@JsonKey(name: 'DOI')
String? doi;
@JsonKey(name: 'Quellart')
List<IdValueColor>? typeOfSource;
@JsonKey(name: 'Datei')
List<FilePart>? files;
@JsonKey(name: 'Link zu Server')
String? serverUrl;
@JsonKey(name: 'Autor/in')
List<IdValueColor>? authors;
@JsonKey(name: 'Seiten')
String? pages;
@JsonKey(name: 'Verwendet in Maßnahmendatenblatt')
List<IdValue>? usedInFactsheet;
@JsonKey(name: 'Anmerkung')
String? note;
factory Source.fromJson(Map<String, dynamic> json) => _$SourceFromJson(json);
Map<String, dynamic> toJson() => _$SourceToJson(this);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_db/base_db.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
class SourceRepository extends BaseDB {
@override
IsarCollection collection = isar.sources;
}

View file

@ -1,4 +1,4 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import 'package:json_annotation/json_annotation.dart';

View file

@ -1,9 +1,10 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:isar/isar.dart';
import '../../../../main.dart';
import '../base_db.dart';
import '../../packages/ambito_db/base_db.dart';
class TreeTypeRepository extends BaseDB {
@override
IsarCollection collection = isar.treeTypes;
}

View file

@ -1,65 +0,0 @@
import 'dart:convert';
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/domain/entity/funding_program/funding_program.dart';
import 'package:ambito/src/packages/ambito_api/restclient.dart';
import 'package:ambito/src/packages/ambito_db/repositories/funding_program_repository.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../ambito_db/base_db.dart';
class BaseApi {
Map tables = {};
init() {
tables = jsonDecode(dotenv.get('BASEROW_IDS'));
}
Future<bool> getContent(String table) async {
init();
int tableId = tables[table] ?? 0;
if (tableId > 0) {
var response =
await RestClient().get('$tableId/?user_field_names=true&size=200');
if (response.statusCode == 200) {
var json = _jsonDecoded(response.body);
switch (table) {
case 'tree_type':
for (var treeType in json['results']) {
TreeTypeRepository().put(TreeType.fromJson(treeType));
}
break;
case 'measure':
for (var measure in json['results']) {
MeasureRepository().put(Measure.fromJson(measure));
}
break;
case 'measure_combination':
for (var measureCombination in json['results']) {
MeasureCombinationRepository()
.put(MeasureCombination.fromJson(measureCombination));
}
break;
case 'organism':
for (var organism in json['results']) {
OrganismRepository().put(Organism.fromJson(organism));
}
break;
case 'funding_program':
for (var fundingProgram in json['results']) {
FundingProgramRepository()
.put(FundingProgram.fromJson(fundingProgram));
}
break;
}
return true;
}
return false;
}
return false;
}
dynamic _jsonDecoded(String input) {
return jsonDecode(utf8.decode(input.runes.toList()));
}
}

View file

@ -0,0 +1,103 @@
import 'dart:convert';
import 'package:ambito/src/entity/entities.dart';
import 'package:ambito/src/packages/ambito_api/restclient.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import '../../../main.dart';
import '../ambito_db/base_db.dart';
class BaseApi {
Map tables = {};
init() {
// read table ids from .env file...
tables = jsonDecode(dotenv.get('BASEROW_IDS'));
}
Future<bool> getContent(String table) async {
init();
int tableId = tables[table] ?? 0;
if (tableId <= 0) return false;
var response =
await RestClient().get('$tableId/?user_field_names=true&size=200');
if (response.statusCode != 200) return false;
var json = _jsonDecoded(response.body);
if (table == 'source') {
logger.d(json);
}
var results = json['results'];
final repositoryMap = {
'tree_type': TreeTypeRepository().put,
'measure': MeasureRepository().put,
'measure_combination': MeasureCombinationRepository().put,
'organism': OrganismRepository().put,
'funding_program': FundingProgramRepository().put,
'location_requirements': LocationRequirementsRepository().put,
'reference_implementation': ReferenceImplementationRepository().put,
'business': BusinessRepository().put,
'service_provider': ServiceProviderRepository().put,
'service_provider_contact_person':
ServiceProviderContactPersonRepository().put,
'material': MaterialRepository().put,
'source': SourceRepository().put,
'experience_report': ExperienceReportRepository().put,
'approval_requirement': ApprovalRequirementRepository().put
};
var repositoryFunction = repositoryMap[table];
if (repositoryFunction == null) return false;
for (var item in results) {
var model = _createModelFromJson(table, item);
repositoryFunction(model);
}
return true;
}
dynamic _createModelFromJson(String table, Map<String, dynamic> json) {
switch (table) {
case 'tree_type':
return TreeType.fromJson(json);
case 'measure':
return Measure.fromJson(json);
case 'measure_combination':
return MeasureCombination.fromJson(json);
case 'organism':
return Organism.fromJson(json);
case 'funding_program':
return FundingProgram.fromJson(json);
case 'location_requirements':
return LocationRequirements.fromJson(json);
case 'reference_implementation':
return ReferenceImplementation.fromJson(json);
case 'business':
return Business.fromJson(json);
case 'service_provider':
return ServiceProvider.fromJson(json);
case 'service_provider_contact_person':
return ServiceProviderContactPerson.fromJson(json);
case 'material':
return Material.fromJson(json);
case 'source':
return Source.fromJson(json);
case 'experience_report':
return ExperienceReport.fromJson(json);
case 'approval_requirement':
return ApprovalRequirement.fromJson(json);
default:
return null;
}
}
dynamic _jsonDecoded(String input) {
return jsonDecode(utf8.decode(input.runes.toList()));
}
}

View file

@ -1,12 +1,42 @@
import 'package:ambito/src/domain/entity/entities.dart';
import 'package:ambito/src/entity/approval_requirement/approval_requirement.dart';
import 'package:ambito/src/entity/entities.dart';
import 'package:flutter/foundation.dart';
import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
import '../../../main.dart';
export 'repositories/measure_combination_repository.dart';
export 'repositories/measure_repository.dart';
export 'repositories/organism_repository.dart';
export 'repositories/tree_type_repository.dart';
export 'repositories/_repositories.dart';
class AmbitoIsarDB {
init() async {
await Isar.initialize();
String dir = kIsWeb
? Isar.sqliteInMemory
: (await getApplicationDocumentsDirectory()).path;
const engine = kIsWeb ? IsarEngine.sqlite : IsarEngine.isar;
isar = Isar.open(
schemas: [
ApprovalRequirementSchema,
BusinessSchema,
FundingProgramSchema,
LocationRequirementsSchema,
MeasureSchema,
MeasureCombinationSchema,
NumberFactsheetSchema,
OrganismSchema,
ReferenceImplementationSchema,
ServiceProviderSchema,
ServiceProviderContactPersonSchema,
SourceSchema,
TreeTypeSchema,
],
directory: dir,
engine: engine,
inspector: true,
);
}
}
abstract class BaseDB {
abstract IsarCollection collection;
@ -23,10 +53,12 @@ abstract class BaseDB {
});
}
get(int id) {
// get entity by id
BaseEntity get(int id) {
return collection.get(id);
}
// get all entities of selected collection
List<dynamic> getAll() {
return collection.where().findAll();
}

View file

@ -0,0 +1,15 @@
export '../../../entity/approval_requirement/approval_requirement_repository.dart';
export '../../../entity/business/business_repository.dart';
export '../../../entity/experience_report/experience_report_repository.dart';
export '../../../entity/funding_program/funding_program_repository.dart';
export '../../../entity/location_requirements/location_requirements_repository.dart';
export '../../../entity/material/material_repository.dart';
export '../../../entity/measure/measure_repository.dart';
export '../../../entity/measure_combination/measure_combination_repository.dart';
export '../../../entity/number_factsheet/number_factsheet_repository.dart';
export '../../../entity/organism/organism_repository.dart';
export '../../../entity/reference_implementation/reference_implementation_repository.dart';
export '../../../entity/service_provider/service_provider_contact_person_repository.dart';
export '../../../entity/service_provider/service_provider_repository.dart';
export '../../../entity/source/source_repository.dart';
export '../../../entity/tree_type/tree_type_repository.dart';

View file

@ -1,5 +1,4 @@
import 'package:ambito/src/extensions/extensions.dart';
import 'package:ambito/src/packages/ambito_db/repositories/measure_repository.dart';
import 'package:ambito/src/entity/measure/measure_repository.dart';
import 'package:ambito/src/widgets/form/fields/field_dropdown.dart';
import 'package:ambito/src/widgets/form/fields/field_monthsrangepicker.dart';
import 'package:ambito/src/widgets/form/form_widget.dart';
@ -10,7 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import '../../../main.dart';
import '../../domain/entity/entities.dart';
import '../../entity/entities.dart';
class ActionsPage extends StatefulWidget {
const ActionsPage({super.key});
@ -46,8 +45,10 @@ class ActionsPageState extends State<ActionsPage> {
support = {};
}
buildCards() {}
@override
Widget build(BuildContext context) {
// Step 1: Collect all distinct values in each Set in a single loop
final updatedTypes = <String>{};
final updatedAreaTypes = <String>{};
final updatedSupports = <String>{};
@ -71,7 +72,6 @@ class ActionsPageState extends State<ActionsPage> {
});
}
// Step 2: Update state with collected data in a single setState() call
setState(() {
type.addAll(updatedTypes);
areaType.addAll(updatedAreaTypes);
@ -79,7 +79,6 @@ class ActionsPageState extends State<ActionsPage> {
months.addAll(updatedMonths);
});
// Step 3: Generate the list of action cards with matching filters
final actionCards = massnahmen.map((massnahme) {
final typeMatches =
filterType == null || massnahme.actionGroup?.value == filterType;
@ -92,7 +91,6 @@ class ActionsPageState extends State<ActionsPage> {
?.any((aType) => aType.value == filterSupport) ??
false);
// Update visibility in a single batch setState()
setState(() {
visible[massnahme.id] =
typeMatches && areaTypeMatches && supportMatches;
@ -101,21 +99,33 @@ class ActionsPageState extends State<ActionsPage> {
return getCard(context, massnahme);
}).toList();
// Step 4: Return UI widget structure
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.translate('page.actions.title'),
style: Theme.of(context).textTheme.headlineLarge,
getSpacer(),
Center(
child: SearchBar(
leading: const Icon(Icons.search),
onChanged: (value) {
for (Measure massnahme in massnahmen) {
if (!massnahme.name!.contains(value)) {
logger.d('$value not in ${massnahme.name}');
setState(() {
visible[massnahme.id] = false;
});
} else {
logger.d('$value in ${massnahme.name}');
setState(() {
visible[massnahme.id] = true;
});
}
}
},
),
),
getSpacer(),
Text(
context.translate('page.actions.intro'),
style: Theme.of(context).textTheme.titleLarge,
),
getSpacer(),
Expanded(
child: Row(
@ -210,7 +220,7 @@ class ActionsPageState extends State<ActionsPage> {
for (int i = 1; i <= 12; i++) {
monthsSorted
.add(FlutterI18n.translate(context, 'general.lists.months.$i'));
.add(FlutterI18n.translate(context, '_general.lists.months.$i'));
}
fields.add(
@ -231,12 +241,12 @@ class ActionsPageState extends State<ActionsPage> {
Widget getCard(BuildContext context, Measure massnahme) {
final Map<String, Color> actionGroupColors = {
'Baulelemente': const Color(0xffFFD269),
'Begrünung': const Color(0xff40DD74),
'Bewirtschaftung': const Color(0xffBF72ED),
'Nisthilfe': const Color(0xffDAE3FD),
'Pflanzung': const Color(0xff40D6E9),
'Sondermaßnahmen': const Color(0xff689EF1),
'Baulelemente': const Color(0xffFFD269).withOpacity(.4),
'Begrünung': const Color(0xff40DD74).withOpacity(.4),
'Bewirtschaftung': const Color(0xffBF72ED).withOpacity(.4),
'Nisthilfe': const Color(0xffDAE3FD).withOpacity(.4),
'Pflanzung': const Color(0xff40D6E9).withOpacity(.4),
'Sondermaßnahmen': const Color(0xff689EF1).withOpacity(.4),
};
Color background =
@ -249,43 +259,65 @@ class ActionsPageState extends State<ActionsPage> {
child: SizedBox(
width: 800,
child: Card(
color: background,
child: Padding(
padding: const EdgeInsets.all(32),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(image != null)
? image
: const SizedBox(
width: 300,
height: 140,
),
const SizedBox(
width: 16,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(massnahme.name!,
style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(
height: 8,
),
ExpandableText(
massnahme.factsheetDefinition ?? '',
maxLines: 3,
expandText: 'mehr',
collapseText: 'weniger',
)
],
elevation: 2,
color: Colors.white,
child: ClipPath(
clipper: ShapeBorderClipper(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Container(
decoration: BoxDecoration(
border: Border(
left: BorderSide(
color: background,
width: 15,
),
)
],
),
),
child: Padding(
padding: const EdgeInsets.all(32),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(image != null)
? image
: const SizedBox(
width: 300,
height: 140,
),
const SizedBox(
width: 16,
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
massnahme.name!,
style: Theme.of(context).textTheme.headlineSmall,
),
const SizedBox(
height: 8,
),
ExpandableText(
style: Theme.of(context).textTheme.bodyLarge,
massnahme.factsheetDefinition ?? '',
maxLines: 4,
expandText: 'mehr',
collapseText: 'weniger',
)
],
),
)
],
),
),
),
),
/*child: ,*/
),
),
);

View file

@ -27,28 +27,21 @@ class StartPageState extends State<StartPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: Row(
children: [
const SizedBox(
width: 30,
automaticallyImplyLeading: false,
leading: Padding(
padding: const EdgeInsets.all(8),
child: Hero(
tag: 'logo',
child: Image.asset(
'assets/images/logo_trans.png',
),
Hero(
tag: 'logo',
child: Image.asset(
'assets/images/logo_trans.png',
width: 50,
height: 50,
),
),
const SizedBox(
width: 30,
),
_linkButton('database'),
],
),
),
leadingWidth: 400,
toolbarHeight: 100,
backgroundColor: Colors.white,
leadingWidth: 80,
centerTitle: true,
title: _linkButton('database'),
toolbarHeight: 80,
backgroundColor: Colors.grey.withOpacity(.4),
actions: [
IconButton(onPressed: () {}, icon: const Icon(Icons.person)),
const SizedBox(
@ -75,12 +68,12 @@ class StartPageState extends State<StartPage> {
}
Widget _linkButton(String link) {
double fontSize = 24;
double fontSize = 20;
return TextButton(
style: ButtonStyle(
overlayColor:
WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
return Colors.white;
return Colors.transparent;
}),
),
onPressed: () {
@ -93,9 +86,7 @@ class StartPageState extends State<StartPage> {
style: TextStyle(
fontSize: fontSize,
fontWeight: FontWeight.bold,
color: (activeLink == link)
? Colors.grey.shade400
: Colors.grey.shade800,
color: (activeLink == link) ? Colors.grey.shade800 : Colors.black,
),
),
);

View file

@ -19,6 +19,7 @@ class FieldDaterangepicker extends FormWidgetField {
final void Function(String?) onSelected;
final List<String> entries;
@override
FormBuilderField get() {
DateTime now = DateTime.now();

View file

@ -18,6 +18,7 @@ class FieldDropdown extends FormWidgetField {
final void Function(String?) onSelected;
final List<String> entries;
@override
FormBuilderField get() {
return FormBuilderDropdown<String>(
name: name,

View file

@ -19,6 +19,7 @@ class FieldMonthsRangepicker extends FormWidgetField {
final void Function(String?) onSelected;
final List<String> entries;
@override
Widget get() {
return SfDateRangePicker(
minDate: DateTime(2024, 1),