Skip to content

Commit

Permalink
Updated visualisations with vector icons for different node types; up…
Browse files Browse the repository at this point in the history
…dated approach to linking to present bi-directional links for more fluid/intuitive link creation; added descriptive link forms to make directionality of links much clearer; simplified related nodes list (for review in search implementation, plus results need to be placed in a sortable table); added cross-node type linking test to selenium tests.
  • Loading branch information
sashaagafonoff committed Oct 20, 2009
1 parent ca001ab commit acc7abb
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 786 deletions.
Binary file modified MASTER/Classifications.xlsx
Binary file not shown.
47 changes: 25 additions & 22 deletions Visualisation Control/src/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

var headingTF:TextFormat = new TextFormat();
headingTF.color = 0xffffffff;
headingTF.bold = true;
headingTF.font = "Arial";
headingTF.size = 12;

Expand All @@ -70,36 +69,40 @@
var ts:TextSprite = new TextSprite(ns.data.name,nodeTF);
ns.addChild(ts);
ns.width = ts.width;

//var rs:RectSprite = new RectSprite( -9,-9,18,18,5,5);
var rs:Sprite = new Sprite();


var rs:Sprite = new Sprite;

if (ns.data.node_class == "person") {
rs.graphics.lineStyle(3, 0xffFF9933);
rs.graphics.beginFill(0xffFF9933, 0.5);
if (ns.data.sex == "Female") {
rs.addChild(new female);
} else {
rs.addChild(new male);
}
} else if (ns.data.node_class == "organisation") {
rs.graphics.lineStyle(3, 0xff00CC99);
rs.graphics.beginFill(0xff00CC99, 0.5);
rs.addChild(new organisation);
} else if (ns.data.node_class == "location") {
rs.graphics.lineStyle(3, 0xff9999CC);
rs.graphics.beginFill(0xff9999CC, 0.5);
rs.addChild(new location);
} else if (ns.data.node_class == "reference") {
rs.graphics.lineStyle(3, 0xff3399CC);
rs.graphics.beginFill(0xff3399CC, 0.5);
switch(ns.data.reference_type) {
case "email":
rs.addChild(new email);
break;
default:
rs.addChild(new reference);
}
} else if (ns.data.node_class == "event") {
rs.graphics.lineStyle(3, 0xffFFFF99);
rs.graphics.beginFill(0xffFFFF99, 0.5);
rs.addChild(new event);
} else { // shouldn't happen
rs.graphics.lineStyle(1, 0x000000);
rs.graphics.beginFill(0xffffff, 0.3);
rs.addChild(new reference);
}

rs.graphics.drawCircle(0, 0, 7);

// center below circle
ts.x = rs.x - ts.width / 2 + 2;
ts.y = rs.y + 10;
rs.x = -20;
rs.y = -20;

// center below circle
ts.x = rs.x - ts.width / 2 + 15;
ts.y = rs.y + 40;

ns.addChildAt(rs, 0); // at position 0 so that the text label is drawn above the rectangular box
ns.size = 0;
ns.mouseChildren = false;
Expand Down
54 changes: 26 additions & 28 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ApplicationController < ActionController::Base

def linker(params)

@origin = Neo4j.load(params[:origin_id]) if params[:origin_id]
@target = Neo4j.load(params[:target_id]) if params[:target_id]
@origin = Neo4j.load(params[:origin_id])
@target = Neo4j.load(params[:target_id])

# construct predicate type
@rel_string = params[:origin_type] + "_to_" + params[:target_type]
Expand All @@ -27,59 +27,57 @@ def linker(params)
when "person_to_person"
rel = @origin.person_to_person.new(@target)
when "person_to_organisation"
rel = @origin.person_to_org.new(@target)
rel = @origin.person_to_organisation.new(@target)
when "person_to_location"
rel = @origin.person_to_loc.new(@target)
rel = @origin.person_to_location.new(@target)
when "person_to_event"
rel = @origin.person_to_event.new(@target)
rel = @origin.person_to_event.new(@target)
when "person_to_reference"
rel = @origin.person_to_ref.new(@target)
rel = @origin.person_to_reference.new(@target)

when "organisation_to_person"
rel = @target.person_to_org.new(@origin) # note that the direction of the relationship necessitates inversion of the creation order
rel = @origin.organisation_to_person.new(@target)
when "organisation_to_organisation"
rel = @origin.org_to_org.new(@target)
rel = @origin.organisation_to_organisation.new(@target)
when "organisation_to_location"
rel = @origin.org_to_loc.new(@target)
rel = @origin.organisation_to_location.new(@target)
when "organisation_to_event"
rel = @origin.org_to_event.new(@target)
rel = @origin.organisation_to_event.new(@target)
when "organisation_to_reference"
rel = @origin.org_to_ref.new(@target)
rel = @origin.organisation_to_reference.new(@target)

when "location_to_person"
rel = @target.person_to_loc.new(@origin)
rel = @origin.location_to_person.new(@target)
when "location_to_organisation"
rel = @target.org_to_loc.new(@origin)
rel = @origin.location_to_organisation.new(@target)
when "location_to_location"
rel = @origin.loc_to_loc.new(@target)
rel = @origin.location_to_location.new(@target)
when "location_to_event"
rel = @target.org_to_event.new(@origin)
rel = @origin.location_to_event.new(@target)
when "location_to_reference"
rel = @origin.org_to_ref.new(@target)
rel = @origin.location_to_reference.new(@target)

when "event_to_person"
rel = @target.person_to_event.new(@origin)
rel = @origin.event_to_person.new(@target)
when "event_to_organisation"
rel = @target.org_to_event.new(@origin)
rel = @origin.event_to_organisation.new(@target)
when "event_to_location"
rel = @origin.event_to_loc.new(@target)
rel = @origin.event_to_location.new(@target)
when "event_to_event"
rel = @origin.event_to_event.new(@target)
rel = @origin.event_to_event.new(@target)
when "event_to_reference"
rel = @origin.event_to_ref.new(@target)
rel = @origin.event_to_reference.new(@target)

when "reference_to_person"
rel = @target.person_to_ref.new(@origin)
rel = @origin.reference_to_person.new(@target)
when "reference_to_organisation"
rel = @target.org_to_ref.new(@origin)
rel = @origin.reference_to_organisation.new(@target)
when "reference_to_location"
rel = @target.loc_to_ref.new(@origin)
rel = @origin.reference_to_location.new(@target)
when "reference_to_event"
rel = @target.event_to_ref.new(@origin)


rel = @origin.reference_to_event.new(@target)
when "reference_to_reference"
rel = @origin.ref_to_ref.new(@target)
rel = @origin.reference_to_reference.new(@target)

end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ def graphml
end

def show
@references = Reference.all.nodes
@organisations = Organisation.all.nodes
@people = Person.all.nodes
@locations = Location.all.nodes
@events = Event.all.nodes
@references = Reference.all.nodes.to_a
@organisations = Organisation.all.nodes.to_a
@people = Person.all.nodes.to_a
@locations = Location.all.nodes.to_a
@events = Event.all.nodes.to_a
end

def link
Expand Down
108 changes: 32 additions & 76 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module ApplicationHelper
def get_top_menu_style(controller_type)
case controller_type.to_s
when "PeopleController"
@people_style = "color: #f1c130"
@people_style = "color: #f1c130;"
when "OrganisationsController"
@org_style = "color: #f1c130"
@org_style = "color: #f1c130;"
when "EventsController"
@event_style = "color: #f1c130"
@event_style = "color: #f1c130;"
when "LocationsController"
@location_style = "color: #f1c130"
@location_style = "color: #f1c130;"
when "ReferencesController"
@reference_style = "color: #f1c130"
@reference_style = "color: #f1c130;"
end
end

Expand All @@ -31,88 +31,43 @@ def relationship_date_range(edge)
end

def get_relationship_description(edge)

case edge.start_node.class.to_s
when "Person"
if (edge.end_date == "" || edge.end_date > Date.today.to_s) then
if (edge.start_node.sex == "Male") then
@link_desc = "link_desc_male"
else
@link_desc = "link_desc_female"
end
else # for past relationships
if (edge.start_node.sex == "Male") then
@link_desc = "link_desc_male_past"
else
@link_desc = "link_desc_female_past"
end
end
else
if (edge.end_date == "" || edge.end_date > Date.today.to_s) then
@link_desc = "link_desc_male"
else
@link_desc = "link_desc_male_past"
end
if (edge.end_date == "" || edge.end_date > Date.today.to_s) then
@link_desc = "link_desc"
else # for past relationships
@link_desc = "link_desc_past"
end
xml = File.open("#{RAILS_ROOT}/config/relationships.xml")
doc = Document.new(xml)
@xpath_query = '//relationships/relationship[@name="' + edge.name + '"]/' + @link_desc
@edge_name = edge.name
@xpath_query = '//relationships/relationship[@name="' + @edge_name + '"]/' + @link_desc
@rel_desc = XPath.first(doc, @xpath_query).text

end

def get_type_list(origin_type, target_type)
case # this annoying set of nested case statements switch the order for the purposes of matching against the rel types in relationships.xml
when (origin_type == "organisation" and target_type == "person")
origin_type = "person"
target_type = "organisation"
when origin_type == "event"
case target_type
when "person"
origin_type = "person"
target_type = "event"
when "organisation"
origin_type = "organisation"
target_type = "event"
end
when origin_type == "location"
case target_type
when "person"
origin_type = "person"
target_type = "location"
when "organisation"
origin_type = "organisation"
target_type = "location"
when "event"
origin_type = "event"
target_type = "location"
end
when origin_type == "reference"
case target_type
when "person"
origin_type = "person"
target_type = "reference"
when "organisation"
origin_type = "organisation"
target_type = "reference"
when "event"
origin_type = "event"
target_type = "reference"
when "location"
origin_type = "location"
target_type = "reference"
end
end
def get_type_list(origin_type, target_type, origin_gender)
xml = File.open("#{RAILS_ROOT}/config/relationships.xml")
doc = Document.new(xml)
@drop_list_display = '//relationships/relationship[@subject="' + origin_type + '" and @object="' + target_type + '"]/option' # /text() will return just node values
case origin_gender
when "Male"
@gender_modifier = ' and (@gender_specific="male" or @gender_specific="neutral")'
when "Female"
@gender_modifier = ' and (@gender_specific="female" or @gender_specific="neutral")'
else
@gender_modifier = ''
end
@drop_list_display = '//relationships/relationship[@predicate="' + origin_type + '_to_' + target_type + '"'+ @gender_modifier +']/option' # /text() will return just node values
@drop_list_display_hash = XPath.match(doc, @drop_list_display)

return @drop_list_display_hash

end

# generic traverser to 2 levels deep for entire link set - can easily replace with filtered search like /views/shared/_filtered_target.html.haml

def get_gender(object)
if object.class.to_s == "Person" then
if (object.sex.nil?) then "neutral" else object.sex end
else
"neutral"
end
end

# generic traverser to 2 levels deep for entire link set - can easily replace with filtered traversals using both(:link_type)

def convert_to_graphml(object)

Expand Down Expand Up @@ -168,6 +123,7 @@ def graphml_builder(node)
<data key="name">' + [node.first_name, node.surname].join(" ") + '</data>
<data key="first_name">' + (if(node.first_name=='') then 'EMPTY' else node.first_name end) + '</data>
<data key="surname">' + (if(node.surname=='') then 'EMPTY' else node.surname end) + '</data>
<data key="sex">' + (if(node.sex=='') then 'EMPTY' else node.sex end) + '</data>
<data key="date_of_birth">' + (if(node.date_of_birth=='') then 'EMPTY' else node.date_of_birth end) + '</data>
<data key="title">' + (if(node.title=='') then 'EMPTY' else node.title end) + '</data>
<data key="notes">' + (if(node.notes=='') then 'EMPTY' else node.notes end) + '</data>
Expand Down
2 changes: 0 additions & 2 deletions app/helpers/events_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/locations_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/organisations_helper.rb

This file was deleted.

3 changes: 0 additions & 3 deletions app/helpers/people_helper.rb

This file was deleted.

2 changes: 0 additions & 2 deletions app/helpers/references_helper.rb

This file was deleted.

15 changes: 10 additions & 5 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ class Event

property :title, :description, :event_type, :start_date, :end_date, :notes

has_n(:person_to_event).to(Person).relationship(Role)
has_n(:org_to_event).to(Organisation).relationship(Role)
has_n(:event_to_person).to(Person).relationship(Role)
has_n(:event_to_organisation).to(Organisation).relationship(Role)
has_n(:event_to_event).to(Organisation).relationship(Role)
has_n(:event_to_loc).to(Location).relationship(Role)
has_n(:event_to_ref).to(Reference).relationship(Role)

has_n(:event_to_location).to(Location).relationship(Role)
has_n(:event_to_reference).to(Reference).relationship(Role)

has_n(:person_to_event).from(Person).relationship(Role)
has_n(:organisation_to_event).from(Organisation).relationship(Role)
has_n(:location_to_event).from(Location).relationship(Role)
has_n(:reference_to_event).from(Reference).relationship(Role)

index :title, :event_type

Event::EVENT_TYPES = [
Expand Down
17 changes: 11 additions & 6 deletions app/models/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ class Location

property :apt_office_floor_number, :street_number, :street_name, :street_type, :suburb, :city, :country, :postcode, :notes

has_n(:person_to_loc).from(Person).relationship(Role)
has_n(:org_to_loc).from(Organisation).relationship(Role)
has_n(:event_to_loc).from(Event).relationship(Role)
has_n(:loc_to_loc).to(Location).relationship(Role)
has_n(:loc_to_ref).to(Reference).relationship(Role)

has_n(:location_to_person).to(Person).relationship(Role)
has_n(:location_to_organisation).to(Organisation).relationship(Role)
has_n(:location_to_event).to(Event).relationship(Role)
has_n(:location_to_location).to(Location).relationship(Role)
has_n(:location_to_reference).to(Reference).relationship(Role)

has_n(:person_to_location).from(Person).relationship(Role)
has_n(:organisation_to_location).from(Organisation).relationship(Role)
has_n(:event_to_location).from(Event).relationship(Role)
has_n(:reference_to_location).from(Reference).relationship(Role)

index :street_name, :suburb, :country

Location::LOCATION_TYPES = [
Expand Down
Loading

0 comments on commit acc7abb

Please sign in to comment.