Import tool settings
  • 27 May 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.

Delete imported items

  1. Use the check box to select the items you want to delete from the list
  2. On the drop-down menu above the list, select Delete selected Shape import objects.
  3. Click the Go button.

Shape import events

Select Keycore_import_tools -> Shape import events

  • On the displayed list, you can see the basic data on import events.
  • 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. The required settings include the plan state (plan_state_id) and plan type (plan_type_id).

For example:

{

"plan_state_id": 231830,

"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: The applicable import method (see Shape import methods).
  • Source type: Geometry type, such as a line.
  • Destination model: The full name of the Django model, for example: 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 completed when the data has been saved and the Destination has been correctly set. The field names can be checked on this list when entering the data for the Configuration field.

As 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
  • Destination model: keygwt_address.models.AddressCreatorModel
  • Configuration: {"attrs": {"streetno": "$STREETNO", "streetname_fi": "$STREET", "city_fi": "$CITY", "zipcode": "$ZIP"}, "extra": {"apartments": "$APTS"}}

Was this article helpful?

What's Next