Skip to main content

Administrative Entity

The Administrative Entity module is an extension of the Administrative Division module, and it provides a way to represent additional entities within an administrative boundary. An administrative entity is typically a geographic area that is governed by a specific administrative body or organization. For example, an administrative entity might be a city, a town, a village, or a neighborhood.

In the context of an API, the Administrative Entity module can be used to provide additional information about the entities within each administrative boundary. This information might include the name of the entity, its type (e.g. city, town, village), and any relevant metadata (e.g. population, area, number of schools).

The Administrative Entity module is typically used in conjunction with the Administrative Division module, as each administrative entity should be associated with the administrative division that contains it. This allows the API to provide a hierarchical view of the administrative boundaries, from the highest level (e.g. country) down to the lowest level (e.g. neighborhood).

One example use case for the Administrative Entity module is for adding schools and public facilities within an administrative entity. By associating each school or facility with the appropriate administrative entity, the API can provide a comprehensive view of the facilities available within each area, and allow users to filter or search for facilities by location.

Overall, the Administrative Entity module provides a way to represent additional entities within an administrative boundary and to provide more detailed information about the administrative hierarchy. This can be useful for a wide range of applications, from urban planning to public health to social services.

Models

class AdministrationAttributeDataType:
    text = 1
    number = 2
    option = 3

    FieldStr = {
        text: 'Text',
        number: 'Number',
        option: 'Option'
    }

class AdministrationEntityType(models.Model):
    name = models.CharField(max_length=255)
    description = models.TextField()

class AdministrationEntityTypeAttribute(models.Model):
    administration_entity_type = models.ForeignKey(AdministrationEntityType, on_delete=models.CASCADE)
    name = models.CharField(max_length=255)
    data_type = models.IntegerField(
      choices=AdministrationAttributeDataType.FieldStr.items(),
      default=AdministrationAttributeDatatType.text)
    options = models.JSONField(default=None, null=True)

class Entity(models.Model):
    administration = models.ForeignKey(Administration, on_delete=models.CASCADE)
    administration_entity_type = models.ForeignKey(AdministrationEntityType, on_delete=models.CASCADE)
    address = models.CharField(max_length=255)
    coordinates = models.PointField()

class AdministrationEntityValue(models.Model):
    entity = models.ForeignKey(Entity, on_delete=models.CASCADE)
    attribute = models.ForeignKey(AdministrationEntityTypeAttribute, on_delete=models.CASCADE)
    value = models.JSONField()
Administration Entity Type

This model represents the type of administrative entity, such as schools, health facilities, or parks. It might include fields like name or description. Example:

id
name
description
1
Schools
Schools available in the division
Administration Entity Type Attribute

This model represents the attributes of a given administrative entity type, such as the name of the school, the number of students, or the type of school. It might include fields like name, description, or data type.

id
administration_entity_type_id
name
data_type
options
1 1
School Name
1
null
2
1
School Type
3
["Boys School","Girl School", "Public School", "Private School"]
3
1
Number of Students
2
null
Entity

This model represents the relationship between an administrative entity and the division that contains it.

id
administration
administration_entity_type_id
address
coordinates
1
42
1
Jl. Kemang Raya No.36, RT.12/RW.5, Bangka, Kec. Mampang Prpt., Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12150
(-6.262371400000001, -6.262371400000001)
Administration Entity Value

This model represents the values of the attributes for a given administrative entity. It might include fields like entity_id (the ID of the administrative entity), attribute_id (the ID of the administrative entity attribute), and value (the value of the attribute for the entity).

id
entity_id
administration_entity_type_id
value
1
1
1
SD Pelita Harapan Kemang
2
1
2
Private School
3
1
3
90