Import tool settings
  • 01 Aug 2024
  • 2 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Import tool settings

  • Dark
    Light
  • PDF

Article summary

Import tool settings require in-depth understanding of the system. The person modifying the settings must know the full names of the Django models and modules used for data import. In addition, setting the default values of objects may require the retrieval of foreign key values from the database.

Shape import objects

Select Keycore_import_tools -> Shape import objects

On the displayed list, you can see the import status of each object. Imported network objects are not deleted one-by-one on this page, but an entire event will be deleted. See the chapter Deleting a shape import event and the related objects.

Shape import events

  1. Select Keycore_import_tools -> Shape import events
  2. On the displayed list, you can see the basic data on import events.
  3. Open a single event to view a more detailed event log.

Deleting a shape import event and the related objects

  1. Select the import event(s) to be deleted.
  2. On the drop-down menu above the list, select Delete with imported objects.
  3. Click the Go button.

Shape import methods

  • Name: name used on the admin site.
  • Label [fi]... Label [en]: name and its translations displayed to the user.
  • Module: module used in the import.
  • Options: JSON configuration for the import. Mandatory configurations include the following: the plan state (plan_state_id), plan type (plan_type_id) and the type of import report (see the following chapters: Plan state and Plan type).

For example:

{
"plan_state_id": 231830,

"import_report_type": 1210,

"plan_type_id": 231990

}

Check the values in the PLAN_STATE and PLAN_TYPE groups under Text constants. The type of import report is obtained from the list of External document types (see the External document types) chapter. If these values are missing or incorrect, the import will fail.

Shape import mapping configuration

  • Method: applicable import method (see the Shape import methods chapter).
  • Source type: geometry type, such as a line.
  • Destination model: full name of the Django model, such as: keyrns_core.models.Cable
  • Options: data in JSON format, with an “attrs” value that includes a set of key/value pairs for defining the network object data to be imported.

In key/value pairs, the key (on the left) is equivalent to a single field for a network object (for example, cable type, stroke color, placement scale for telecom premises) and the value (on the right) can be either a fixed text or number, or a special variable, the value of which is retrieved from the source data, meaning either a shape file or CSV file. When a variable is used, add the character $ in front of it and enter the field name by using the font size used in the source data.

  • An example:

{"attrs": {

  • "CableType_id": 12930,
  • "State_id": 330,
  • "Remarks": "$comments"
  • }
  • }

In this example, the CableType_id- and State_id fields are foreign keys for another table, and a comments field from the data to be imported will be entered in the Remarks field.

It is easier to complete these fields on the admin page because the list of fields will be created under the text field when the Destination model field has been completed correctly and the data has been saved.

  • Refresher: fields for the object. This will be regenerated when the data has been saved and the Destination has been correctly defined. The field names can be checked on this list when entering the data for the Configuration field.

An example: importing addresses

The configuration depends on the format of the original file.

The address file in this example:

CITY,ZIP,APTS,STREETNO,STREET,X,Y

Kuikkavesi,65530,1,1,Kuikkukatu,3459116.25,6710938.97

Kuikkavesi,65530,1,2,Kuikkukatu,3459079.20,6710953.52

Kuikkavesi,65530,4,3,Kuikkukatu,3459144.03,6710958.82

Required configuration:

  • Method: address [keycore_import_tools_shcape_import.methods.simple.simple]
  • Source type: Point
  • Object: keygwt_address.models.AddressCreatorModel
  • Settings:{"attrs": {"streetno": "$STREETNO", "streetname_fi": "$STREET", "city_fi": "$CITY", "zipcode": "$ZIP"}, "extra": {"apartments": "$APTS"}}

Was this article helpful?