SlideShare a Scribd company logo
1 of 117
cuACS
Requirements Analysis Document
Nicholas Aubé 101032093
Ibiduneyitayo, 101018199
Peter MacDonald, 100683150
Submitted to:
Dr. Christine Laurendeau
COMP 3004 Object-Oriented Software Engineering
School of Computer Science
Carleton University
1
Table of Contents
Introduction + Overview of
Document……………………………………………………………
……………….1
Functional
Requirements…………..……………………………………………
………..……………………………..2
Non-functional
Requirements…………………………………………………………
……………………………2-4
Use Case
Model…………………………………………………………………
………………………….……………4-15
Object
Model…………………………………………………………………
…………………………………………...…16
Introduction
The cuACS program is designed to find the best possible
matches between a variety
of different animals and clients that are looking for a new pet.
The Carleton University
Animal Case System will revolutionize the way that we adopt
animals. The main advantage
of the cuACS system is the dynamic algorithm that matches
shelter animals and human
clients based on compatibility factors such as habitat, size, and
temperament. The
algorithm is optimized to create the largest number of sufficient
matches, not just one or
two perfect ones. The cuACS program will allow clients to look
at animal profiles and edit
their own detailed profiles. There will also be functionality to
manage client profiles and
animal preferences. There are even multiple types of users that
can access the system, staff
and clients. Both types of users have different permissions,
which will be managed by the
system.
This report will cover many different aspects of the cuACS
system, including an
overview of the program, functional and non-functional
requirements, the user case model
and the object model.
2
Functional requirements
Traceability: functional requirements are preceded by the letter
F when referred to in
other sections of the requirements analysis. E.g. F-1.1 refers to
the staff interaction 1.1
functional requirement.
1. Staff interactions
1.1. Staff should be able to add new animals and clients
1.2. Staff should be able to view client and animal information
1.3. Staff should be able to edit animal and client profiles
1.4. Staff should be able to start the Matching algorithm process
1.5. Staff should be able to view a summary of matches made by
the Matching algorithm
1.6. Staff should be able to view the details of a specific match
made by the algorithm
2. Client interactions
2.1. Clients can view and edit their profile
2.2. Clients can view animal profiles
3. Algorithm
3.1. There should be an algorithm that can create optimal
matches between clients and
animals
3.2. The algorithm should look at client preferences and match
them with animal traits
3.3. The algorithm should attempt to create the largest number
of acceptable matches
possible rather than a small number of extremely compatible
matches.
3.4. The algorithm should provide output in a form that can be
easily turned into a
report for user reading.
Non-Functional Requirements
Traceability: non-functional requirements are preceded by the
letters NF when referred
to in other sections of the requirements analysis. E.g. NF-1.1
refers to the open source
licensing non-functional requirement.
1. Legal
1.1. Our software must be distributed under an open source
licence
1.2. Our software’s use of the QT framework must conform to
the terms of its
Open-Source GPL 3.0 licence.
1.3. Our software must be licensed for non-profit use only
2. Usability
2.1. All error messages should be descriptive and, where
applicable, suggest
solutions
3
2.2. The GUI should provide hotkey shortcuts for common tasks
on relevant
platforms
2.3. The database should be automatically updated when users
have finished
editing a profile, without requiring them specific user input.
3. Reliability
3.1. If the system fails while a profile is being updated they
should be prompted
to save their progress
3.2. The system should be able to perform the functional
requirements without
crashing, hanging, or otherwise failing.
3.3. The system should consistently be able to run without
crashing after release
4. Performance
4.1 The matching algorithm should provide results in a
reasonable time frame
(< 60 seconds).
4.2 The program should minimize both system resources and
system time by
ensuring that unnecessary calls to the database are avoided
4.3 When running the matching algorithm, the thread that is
handling UI
processes should not be blocked while waiting for the results.
5. Supportability
5.1. The back-end and the GUI should be sufficiently decoupled
that porting the
system to a different GUI framework would be easy
5.2. Adding, removing, or modifying animal and client traits
should be easy
5.3. Modifying one part of the GUI should not require remaking
other portions to
preserve functionality
6. Implementation
6.1. The system must be written in C++
6.2. The system needs to have a GUI
6.3. Persistent storage must be provided through an SQL
database
7. Interface
7.1. The interface should be clean and professional
7.2. The interface needs to have a sign in as either a staff
member or a client
7.3. The interface should be designed and programmed using the
QT framework
8. Operations
8.1. The client should not be able to access the information of
other clients
8.2. The client should not be able to modify the information of
animals
8.3. Only staff members can create client profiles and
9. Packaging
9.1. The system should build in a single command and run with
a single
command
9.2. The system must be accessible as an executable for
download
4
9.3. The codebase should be packaged in a way that it is easy to
navigate and
intuitive for all programmers to be able to easily find the
intended piece of
code
Use Case Model
Diagrams
5
6
7
8
9
10
11
12
Reminder: UC-3.1 refers to the algorithm use case where it
creates matches.
Descriptions
Use Case Identifier UC-1.1/UC-1.2
Name StaffAddClient/StaffAddAnimal
Participating actors StaffMember
Flow of events 1. A staff member starts the creation process
2. The program creates the form to initialize the new item’s
properties
3. The staff member fills out the form and submits it
4. The program will add the new client/animal to the
appropriate
table after verifying that all the fields are entered correctly
Entry conditions The Staff member elects to begin the creation
process
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.1
13
Use Case Identifier UC-1.3/UC1.4
Name StaffViewClient/StaffViewAnimal
Participating actors StaffMember
Flow of events 1. A staff member selects the client or animal
profile that they
would like to view
2. The staff member clicks on the view details button
3. The program opens the details page for the client or animal
Entry conditions The Staff member elects to open the details
page
Exit conditions The program returns back to the main menu
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.2
Use Case Identifier UC-1.5/UC1.6
Name StaffEditClient/StaffEditAnimal
Participating actors StaffMember
Flow of events 1. A staff member starts the edit process
2. The program creates the form to edit the item’s properties
3. The staff member fills out the form and submits it
4. The program will update the client/animal to the appropriate
table after verifying that all the fields are entered correctly
Entry conditions The Staff member elects to open the edit page
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.3
Use Case Identifier UC-1.7
Name StaffStartAlgorithm
Participating actors StaffMember
Flow of events 1. A staff member starts the algorithm
2. The program creates the appropriate matches and saves them
Entry conditions The Staff member elects to start the algorithm
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.4
Use Case Identifier UC-1.8
Name StaffViewMatchSummary
Participating actors StaffMember
Flow of events 1. A staff member starts UC-1.7
2. The program creates the appropriate matches and saves them
3. The staff member clicks the summary button of the algorithm
4. The program reprints the general summary of the matches
Entry conditions The Staff member elects to open the summary
of matches
Exit conditions The system will return to the menu
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.5
14
Use Case Identifier UC-1.9
Name StaffViewMatchDetails
Participating actors StaffMember
Flow of events 1. A staff member starts UC-1.7
2. The program creates the appropriate matches and saves them
3. The staff member clicks the details button on a certain match
4. The program prints the summary of that specific match
Entry conditions The Staff member elects to start the algorithm
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the staff portion of
the software.
Traceability F-1.6
Use Case Identifier UC-2.1/UC-2.2
Name ClientViewSelf/ClientEditSelf
Participating actors ClientMember
Flow of events 1. A client clicks on their profile
2. For UC-2.2, the client can press the edit button on their
profile
a) The program creates a form for the user to make changes and
submit
b) The user submits the updated information and the program
checks to make sure it is correct
c) The program updates the client’s profile and returns back to
their
profile page
3. The program displays the client’s profile
Entry conditions The Staff member elects to view their profile
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the client portion of
the software.
Traceability F-2.1
Use Case Identifier UC-2.3
Name ClentViewAnimal
Participating actors ClientMember
Flow of events 1. Client clicks on the animal details button
2. Program fetches and displays the list of animals and their
details
Entry conditions The Staff member elects to open the animals
page
Exit conditions The program returns back to the main menu
Quality requirements The user must be in the client portion of
the software.
Traceability F-2.2
15
Use Case Identifier UC-3.1
Name StaffStartMatches
Participating actors StaffMember
Flow of events 1. The program is called to make matches
2. The algorithm fetches animal information and client
preferences
and creates matches according to all F-3.X functional
requirements
3. The program saves the displays the matches
Entry conditions The Staff member elects begin the matching
algorithm
Exit conditions The system will return a message saying that the
action is complete
Quality requirements The user must be in the staff portion of
the software.
Traceability F-3.1, F-3.2, F-3.3, F-3.4
Object Model
Data Dictionary
Name / ID
Number
Attributes / Associations Definition Use
Cases
User
O-01
• Username
• password
A user of the cuACS system. All use
Cases
Staff User
O-02
• Has access to the
client database
• Has access to the
animal database
• Has access to the
matching system
• Is a User
A user of the cuACS system with
staff/writing privileges.
UC-1.1
UC-1.2
UC-1.3
UC-1.4
UC-1.5
UC-1.6
UC-1.7
UC-1.8
UC-1.9
UC-3.1
Client User
O-03
• Has a client profile in
the Client database
• Has read-only access
to the animal database
• Is a User
A user of the cuACS system with
client privileges.
UC-2.1
UC-2.2
UC-2.3
16
Client
Profile
O-04
• Stored in the client
database
• Can be edited by any
staff user
• Can be edited by one
client user
• Used by the Matching
System to create
Matches
• Name
• Age
• Gender
• Size preference
• Species preference
• Allergies
• Living space
• Activity level
preference
• Family size
A profile in the cuACS system that
describes a client and their
preferences.
UC-1.1
UC-2.1
UC-2.2
UC-2.3
UC-3.1
Animal
Profile
O-05
• Stored in the animal
database
• Can be edited by any
staff user
• Can be viewed by any
Client user
• Used by the Matching
System to create
Matches
• Name
• Species
• Gender
• Weight
• Size
• Color
• Age
• Ease of training
• Playfulness
• Friendliness with
strangers
• Friendliness with
children
• Aggressiveness
• Activity Level
• Affection Level
• Hypoallergenic (yes/no)
• Nocturnal (yes/no)
• Shedding level
• Living area needed
• Ideal habitat
A profile in the cuACS system that
describes an animal kept at the
shelter and up for adoption.
UC-1.1
UC-1.3
UC-1.4
UC-1.5
UC-1.6
UC-1.7
UC-1.8
UC-1.9
UC-3.1
17
• Indoors or outdoors
pet?
• Preferred climate
• Responsiveness to
toys
• Diet
Client
Database
O-06
• Contains client profiles
• Can be read by staff
users
• Can be edited by staff
users
• Can be read by the
Matching System
The database system storing the
client profiles for the cuACS system.
UC-1.1
UC-1.3
UC-1.5
UC-1.7
UC-3.1
Animal
Database
O-07
• Contains animal
profiles
• Can be read by all
users
• Can be edited by staff
users
• Can be read by the
Matching System
The database system storing the
animal profiles for the cuACS
system.
UC-1.2
UC-1.4
UC-1.6
UC-1.7
UC-2.3
UC-3.1
Match
O-08
• Contains one animal
and one client
• Created by the
Matching system
• Can be viewed by staff
users
A match between a client and a
compatible animal, as judged by the
Matching system
UC-1.8
UC-1.9
UC-3.1
Matching
System
O-09
• Can read client
database
• Can read animal
database
• Can be activated and
viewed by staff users
• Creates matches
• Stores matches
This system reads both the client
and animal databases and creates
matches between compatible clients
and animals.
UC-1.7
UC-1.8
UC-3.1
Association Diagrams
18
Fig 1:
19
Fig 2:
INSCRIBED LANDSCAPES
Travel Writing from Imperial China
Translated with Annotations and an Introduction by
RICHARD E. STRASSBERG
UNIVERSITY OF CALIFORNIA PRESS BERKELEY LOS
ANGELES LONDON
16
Fan Chung-yen (989-1052)
j~ 1~ ~~
Fan Chung-yen was born in Su-chou in what is today Chiang-su.
His
father died when he was still young, and he was educated in
Buddhist
temple schools with the support of patrons. Becoming a
Presented
Scholar in 1015, he enjoyed a distinguished career, although he
suffered
demotion three times during his early years in office. He was
nevertheless admired as an idealistic Confucian and achieved
notable
success in military and diplomatic affairs. In 1041, when he was
auxiliary academician of the Dragon Diagram Hall, he was sent
as
assistant military commissioner for the Shaan-hsi Circuit, where
he
fortified a critical area against the Hsi-Hsia Kingdom and
arranged a
durable peace between the two countries. In 1043, he proposed a
reform program-later regarded as the "Minor Reform" of the
Northern Sung, since it antedated the more pervasive reforms of
Ou-
yang Hsiu and Wang An-shih (1021-1086). It failed in 1045
owing to
political opposition. Fan was then assigned to local posts at his
request,
where he continued to serve with distinction as a prefect.
His literary theory embraced the ideals of Ancient Style prose
but
also included interest in the conventions of parallel prose. The
Pavilion
ofYueh-yang was commissioned by a friend, T'eng Tzu-ching
(991-
1047), who, like Fan, was demoted and exiled to the post of
prefect.
Fan wrote the piece from a distance, relying both on his memory
of the
place and on an illustration. It became one of the most widely
known
works of travel literature, combining a documentary function
with a
lyrical description of the scenery that reflects the ambivalent
moods of
the writer. His statement "First feel concern for the concerns of
the
world. Defer pleasure until the world can take pleasure" became
an
enduring motto for Confucian officials. · 157
158 FAN CHUNG-YEN
The Pavilion ofYiieh-yang faces Grotto Lake and was first built
above the West Gate of the city wall ofYiieh-yang in present-
day Hu-
nan during the K'ai-yiian era (713-741) of the T'ang dynasty. It
was
renovated a number of times through the centuries and was
completely
rebuilt in 1867. Presently, its three stories stand about sixty-
five feet
high. Although celebrated as early as the T'ang in a poem by Tu
Fu
(712-770), the pavilion became a literary shrine largely as a
result of
Fan Chung-yen's account. Later, an engraving of this piece
written by
the Ch'ing calligrapher Chang Chao (169I-1745) was placed
inside the
main hall.
The Pavilion ofYiieh-yang *~t!~C. (1046)
In the spring of the fourth year of the Ch'ing-li era [1044],
T'eng Tzu-
ching was demoted to the post of prefect of Pa-ling. 1 Two
years later,
his administration was well ordered and the people lived in
harmony;
numerous affairs that had languished were revived with success.
Then
he had the Pavilion of Yiieh-yang restored, expanding its
original de-
sign. Poems and prose by worthies of the T'ang as well as by
men of
the present dynasty were inscribed upstairs. I was asked to write
a piece
in commemoration.
I have observed the magnificent scenery of Pa-ling at this lake
named "Grotto," which bites the distant mountains and swallows
up
the Long River, surging restlessly as it extends beyond the
horizon. Be-
tween the radiant mornings and the shadowy twilight, its
atmosphere
undergoes myriad transformations. This is the grand view from
the
Pavilion of Yiieh-yang, which ancient writers have described in
detail.
Because the water routes lead north to Shaman's Gorge and
stretch
south all the way to the Hsiao and Hsiang rivers, exiled officials
and
tragic poets have always gathered here. Did they not have
various feel-
ings upon viewing this scene?
When it rains constantly in heavy showers and the sun does not
shine through for months on end, cold winds howl, and muddy
waves
strike at the sky. The sun and stars hide their radiance; the hills
and
mountains conceal their forms. Merchants and travelers cannot
set sail,
for the masts would break and the oars snap. At twilight, all
turns to
darkness: tigers roar and gibbons cry. Ascending to the pavilion
now,
FAN CHUNG-YEN I59
one feels remote from the capital and longs for home, worried
about
slander and fearful of ridicule. A bleak vista fills one's eyes;
regrets in-
tensify and turn to melancholy.
When it turns to balmy spring and the entire scene brightens,
the
waves are no longer aroused. The sky above and its reflection
below
form a single, vast expanse of blue-green. Seagulls soar about
and
gather to rest; colorful fish swim and submerge. Angelica by the
banks
and orchids on the islets diffuse their fragrances as they
flourish. And
sometimes, when the blanketing mist vanishes, the luminous
moon
shines for a thousand li. Floating light beams shimmer like
gold; the
moon's quiet reflection forms a submerged jade disc.
Fishermen's songs
respond to one another. How could one ever tire of such joy?
Ascend-
ing to the pavilion now, one's heart opens and one's spirit is
delighted.
Favor and disgrace are both forgotten as one faces the breeze
with a cup
of wine in boundless satisfaction.
Ah! I have often sought to attain the mind of those ancient
paragons
of humaneness, for some of them did not experience these two
kinds of
feelings. Why was this? They took no delight in external things,
nor
felt sorry for themselves. When they occupied a high position at
court,
they felt concern for the people. When banished to distant rivers
and
lakes, they felt concern for their sovereign. When serving at
court, they
felt concern, when forced to withdraw they felt concern. Then
when
did they enjoy happiness? Would these ancients not have said,
"First
feel concern for the concerns of the world. Defer pleasure until
the
world can take pleasure." Alas! If there were not such people,
then
whom could I follow?
ON THE FIFTEENTH DAY OF THE NINTH LUNAR MONTH
IN THE SIXTH YEAR [OCTOBER I7, I046J2
Fig. 23.
Chin Nung (1687-1773), "Tilt Pavilion oftht
Old Dnmkard" by 0••-yaug Hsiu. Leaf f of
Album of Ltmdscapts Illustrating Poems and
Essays By Famous Writers (1736), Museum
Rietberg, Zurich, Gift of Charles A.
Drenowatz. Ou-yang Hsiu is depicted here
sitting with a companion by the pavilion
with his travel account fully inscribed as a
colophon.
17
Ou-yang Hsiu (1007-1072)
~k~1~
Ou-yang Hsiu was one of the dominant figures ofNorthern Sung
literature and politics, a leader of a circle ofliterary
progressives who
consolidated the ideals of the Ancient Style. Later canonized as
one of
the Eight Masters ofT'ang and Sung Prose, he was a prolific
writer in
a variety of prose and poetic genres. Born in Yung-feng, Chi
Prefecture (modern Chi-shui, Chiang-hsi), Ou-yang entered the
Imperial University after twice failing the prefectural
examinations and,
in 1030, distinguished himself by placing fourteenth in the
palace
examinations. In 1036, he was exiled and demoted for
supporting Fan
Chung-yen's criticisms; he was recalled in 1040 along with Fan
and
rose to become a drafting official because ofhis fame as a
writer. Fan
and his faction again fell from power in 1045. The following
year, Ou-
yang's reputation was damaged by a scandal in which he was
falsely
charged with incest and imprisoned; his known fondness for
singers
and writing romantic poetry may have made him particularly
vulnerable to such charges. After his acquittal, he was once
again exiled
and made prefect of Ch'u Prefecture (modern Ch'u District, An-
hui),
where he wrote The Pavilion of the Old Drunkard, one of his
most
enduring works. Ou-yang Hsiu subsequently served as prefect of
Yang-chou, where he revived his romantic reputation, as well as
prefect ofYing Prefecture (modern Fu-yang, An-hui), a scenic
area
where he later retired. He returned to the capital in 1054 and
became
increasingly influential in the central government, rising to the
powerful position of assistant chief minister. During the
following
period of thirteen years he served as co-editor of The New
History of the
T'ang Dynasty (Hsin T'ang shu, 1060) and single-handedly
wrote The
New History of the Five Dynasties (Hsin Wu-tai shih,
posthumously 161
162 OU-YANG HSIU
published in 1072) as models of the Ancient Style; both works
were
praised by literary stylists but later criticized by historians. He
further
consolidated the position of the Ancient Style when, as chief
examiner
in 1057, he required it in examination essays and failed those
who
wrote in other styles. It was through this examination that he
discovered Su Shih and Su Ch'e, destined to become leading
literary
figures of the next generation. Ou-yang Hsiu served in various
high-
level positions during the 106os, and his administration was
noted for
its stability and several progressive reforms. However, he was
again
falsely accused of incest, though again cleared. He repeatedly
requested
assignments away from the capital and finally, in 1071, was
allowed to
retire with the title of Junior Preceptor of the Heir Apparent.
Ou-yang Hsiu left over five hundred pieces of prose in a variety
of
forms, all characterized by a tight sense of structure. He was
also an
early proponent of the miscellany (pi-chi), producing several
influential collections as well as an early travel diary, Diary of
My Route
to Assume Office (Yii-i chih), written while journeying to a
new post to
which he was demoted in 1036. In The Pavilion of the Old
Drunkard, the
presence of parallelistic elements and syntactical repetitions
create a
sense of playfulness and humor reflecting the informality of the
piece.
Ou-yang was relatively unconcerned with the metaphysics of
Nature
or speculative philosophy; this piece reveals instead his
pragmatic
interest in concrete human activity and in the texture of the
observable
world. Its cumulative effect is to convey Ou-yang Hsiu's
undiminished
humanity and commitment while an official in exile.
The Pavilion of the Old Drunkard (Tsui-weng-t'ing) is located
on
Lang-ya Mountain in the southwest of modern Ch'u District,
An-hui,
about two miles from the city. It was ordered built by Ou-yang
Hsiu
himself, who had the monk Chih-hsien supervise its
construction on a
scenic spot next to a spring. The elegant open building has been
restored many times, and the area abounds in inscriptions dating
back
to the T'ang and Sung. Ou-yang's original calligraphy of the text
was
engraved at the site in 1048 but proved unsuitable for making
rubbings.
In 1091, Su Shih was asked to rewrite the text in larger
characters, and
this engraving was widely reproduced.
The Pavilion of the Old Drunkard !W- ~ .f~C. ( 1046)
Mountains ring the seat of Ch'u Prefecture. 1 The many peaks
on the
southwest are especially beautiful, with their forests and
valleys. I
OU-Y ANG HSIU 163
gazed into the distance at one that was luxuriant, deep, and
graceful-
Lang-ya Mountain. 2 I walked more than two miles up the
mountain
and gradually heard the gurgling sound of water, "ch'an-ch'an,"
until I
found, splashing out from between two peaks-Fermentation
Spring.
The peaks circled around me as the road twisted and turned
until there
was a pavilion with eaves like wings, facing the spring-the
Pavilion of
the Old Drunkard. Who built this pavilion? A monk on the
mountain
-Chih-hsien. Who named this pavilion? The Prefect did, after
himself.
For the Prefect comes here to drink with his guests. After
drinking
only a bit, he quickly becomes drunk, and because he is the
oldest,
he calls himself "the Old Drunkard." But wine is not uppermost
in the Old Drunkard's mind. What he cares about is to be amid
moun-
tains and streams. The joy of the landscape has been captured in
his
heart, and wine drinking merely expresses this.
When the sun appears, the mist disperses through the forest;
when
clouds return to the mountains, the caves in the cliffs darken.
These
transformations from brightness to darkness-such is dawn and
dusk
on the mountain. When wildflowers blossom giving off subtle
fra-
grances, when fine trees flourish providing extensive shade,
when the
wind is clean and the frost is pure, when the water is low and
the rocks
become visible-such are the four seasons in these mountains. If
one
comes here in the morning and returns in the evening, one will
notice
the scenes differing throughout the four seasons and experience
a joy
that is likewise inexhaustible.
Men bearing loads sing along the road, while travelers rest
under
the trees. Those in front call out; those behind respond. The
elderly,
hunched over ones leading the young by the hand as they come
and go
ceaselessly-these are the people of Ch'u on their outings. Along
the
stream they fish: the stream is deep, the fish, stout; they
ferment the
spring water into wine: the water is sweet, the wine, clear.
Various
kinds of mountain game and wild vegetables casually served-
such is
the Prefect's banquet. The gaiety of the feasting and drinking is
unaccompanied by strings or flutes. Someone wins at tossing
arrows
into a pot; another gains victory at chess. Winecups and wine
tallies
crisscross back and forth. Shouting out as they jump up or sit
down-
such is the happiness of all the guests. And the person with the
aged
face and whitened hair who sits slumped among them-the
Prefect,
drunk.
Before long, the sun sets behind the mountain; the people along
with their shadows disperse. The Prefect returns, followed by
his
guests. As the forest covers everything in darkness, cries ring
out all
over-such is the joy of the birds as the visitors depart. The birds
can
164 OU - YANC HSIU
only enjoy the mountains and forests: they cannot understand
the joy
of people. The people can only enjoy this outing along with the
Prefect: they cannot understand that the Prefect was enjoying
their joy.
He who, when drunk, was able to share their joy and, when
sober,
could describe it with literary flourish is-the Prefect. And who
is this
Prefect? Ou-yang Hsiu of Lu-ling. 3
Fig. 24.
Rubbing ofSu Shih's Inscription of Tile
Pavilion o_{joyful Abuuda/l(e (detail. original
ca. 1091 ) . From Su Shih, Fw,~-le-t'i11,~ chi
(rpt. Taipei, 1975).
OU-YANC HSIU 165
The Pavilion of]oyful Abundance t$.f"tC. (1046)
This piece was also written while Ou-yang Hsiu was exiled in
Ch'u
Prefecture. In contrast to the casual attitude of The Pavilion of
the Old
Drunkard, this is a more decorous composition meant to be
publicly
displayed as an explanation of the moral significance of the
pavilion's
name. It displays a historical sense of place, as well as loyal
political
sentiments. Ou-yang Hsiu contrasts the past, a long phase of
disorder
166 OU-YANG HSIU
and suffering, with the present state of peace and prosperity in
which
he implicitly participates. The theme of joyful abundance
enables him
to offer praise to the dynasty that was punishing him for his
views and
to articulate the Confucian virtues that would merit his recall to
the
capital. The pavilion at the foot of Mount Abundance (Feng-
shan) near
Lang-ya Mountain was also ordered built by Ou-yang Hsiu in
1046 in
order to celebrate the bountiful era. Standing beside a spring
surrounded by a tall peak and bamboo-covered hills, it became a
frequent destination for his excursions. The text was also
rewritten by
Su Shih and engraved at the site.
Only in the summer of the second year after I took office in
Ch'u
Prefecture was I able to taste the spring water hereabouts and
discover
its sweetness. When I asked a local person about it, I found that
it had
come from the south of the prefectural city, no more than a
hundred
paces away. Above it stood Abundance Mountain, 1 lofty and
strikingly
erect; below it was a secluded valley, remote and shady, and
hidden
deep. Between them was a pure spring overflowing and spurting
up-
ward. I gazed up and peered down to the left and right, and was
de-
lighted at what I observed. So I cut through the rocks to make a
path
for the spring, and cleared some land for a pavilion so that I
could
make excursions here along with the people of Ch'u.
Ch'u was a battlefield during the wars of the Five Dynasties.
Formerly, Emperor T'ai-tsu of the Sung2 led the army of the
Latter
Chou to defeat the 150,000 troops of Li Ching at the foot of
Pure
Stream Mountain. 3 He took prisoner Generals Huang-fu Hui
and Yao
Feng outside the East Gate of the city of Ch'u Prefecture, finally
pacify-
ing Ch'u. 4 I investigated the terrain, consulted maps and
records,
climbed up high to observe Pure Stream Pass, and sought to find
the
place where Huang-fu Hui and Y ao Feng were captured. But
there
were no living survivors, for it has been a long time since peace
was
established through the empire.
After the T'ang dynasty lost control, the entire land split apart.
Strongmen arose and fought each other. Were not those warring
king-
doms beyond counting? Then, when the Sung received the
Mandate of
Heaven, a sage arose and unified all within the four seas. 5 The
strategic
bases of those contenders have been demolished and leveled. A
century
later, all is peaceful: nothing remains except the tall mountains
and pure
streams. I wanted to inquire about these events, but the
survivors are
OU-Y ANG HSIU I67
all gone now. Nowadays, Ch'u Prefecture is located between the
Long
and Huai rivers, yet merchants and travelers do not come here.
The
people are unaware of events outside and are content with
farming and
providing clothing and food so that they are happy in life and
provided
for in death. But who among them realizes that it is the
achievements
and virtue of Our Sovereign which has allowed them to thrive
and
prosper, flourishing for as long as a century?
When I came here, I was delighted by the isolation of the place
and
the simplicity of official business. I was especially fond of the
relaxed
way oflife. So, ever since discovering this spring in a mountain
valley,
I have come here daily together with the people of Ch'u to look
up-
ward and gaze at the mountain and to peer down to listen to the
spring.
I gather hidden flowers and seek shade under the lofty trees. I
have
visited it in wind, frost, ice, and snow, when its pure beauty is
revealed.
The scenery during the four seasons is always charming.
Moreover, it
is fortunate that the people are joyful over the abundant
harvests and
are happy to travel here together with me. I have used this
landscape to
praise the excellence of their customs so as to remind the people
that
they can rest content in the joy of this year's abundant harvest,
because
they are fortunate enough to live during a time free from
trouble.
To proclaim the benevolence and virtue of Our Sovereign and
share
the joy of the people is the duty of a prefect. Thus, I have
written this
account and named the pavilion after this.
WRITTEN BY OU-YANG HSIU, EXHORTER ON THE RIGHT,
PROCLAMATION
DRAFTER, AND PREFECT OF CH'U AND CHUN
PREFECTURES, IN THE SIXTH MONTH
OF THE YEAR PING-HSU DURING THE CH'ING-LI ERA
[JULY-AUGUST I046) 6
2I
Su Shih (1037-1101)
Su Shih, widely known by his artistic name, Tung-p'o (Eastern
Slope),
became one of the dominant figures in Chinese literati culture,
influencing not only prose and poetry but aesthetic theory,
painting,
and calligraphy as well. He was born into a gentry family
oflimited
means and educated primarily by his father, Su Hsiin (1009-
1066), later
famous as a political essayist, and also by his mother, nee
Ch'eng. He
and his younger brother, Su Ch'e, were regarded as newly
discovered
talents after passing the Presented Scholar examination in 1057
under
Ou-yang Hsiu. In 1061, Su Shih passed the special examination
held to
recruit new officials and began his career as a case reviewer at
the Court
of Judicial Review. During these early years, he wrote
numerous
memorials identifying critical national problems in areas of
finance and
military defense. Although interested in reform, he opposed
Wang An-
shih's New Policies, objecting to the dislocation caused by their
rapid
implementation and Wang's use oflegalist methods. In 1079, Su
was
arrested in a "literary inquisition" for allegedly defaming the
court in
one of his poems. After several months of investigation, he was
released, demoted to the nominal post of assistant military
training
commissioner, and exiled to Huang Prefecture in what is today
Hu-pei.
There, he wrote some of his best-known travel pieces while
continuing
to address current issues. Given a slight promotion to Ju
Prefecture in
1084, he passed through Nanking on his way and met Wang An-
shih,
with whom he continued to maintain cordial literary relations
despite
political differences.
Su Shih returned to the capital after the reversal ofWang's
policies
~~
under the Empress Dowager Hsiian-jen, regent for the young
Emperor 183
184 S U SHIH
Fig . .z8.
Wu Yiian-chih (active late 12th cent. ), Red
C/!ff(detail). National Palace Museum, Taipei.
Che-tsung (r. I08s-noo), and served as a Han-lin Academician
when
the conservative party of Szu-ma Kuang gained power. He
angered
them, however, when he protested the indiscriminate
dismantling of
Wang's New Policies, with none of their beneficial aspects
preserved,
and was sent to administer Hang-chou in 1089. A series of other
local
posts followed in which he was able to institute progressive
changes
despite the reigning conservative atmosphere. In 1094 when the
Che-
tsung Emperor assumed personal rule, another faction
supplanted those
favored under the Empress Dowager, and Su Shih was again
exiled,
this time to remote Hai-nan Island in the south, where living
conditions were particularly severe. H ere, coo, he wrote travel
pieces,
which continued to express his acceptance of the vicissitudes of
life and
SU SHIH 185
a vitalistic engagement with his surroundings. Pardoned in 1100
upon
the accession of the Emperor Hui-tsung (r. II00-1125), he died
the
following year while on his way north.
Though an activist Confucian official, Su Shih was eclectic in
his
intellectual interests. He was deeply influenced by Ch'an
Buddhist
concepts of enlightenment, the mind, and human nature, and
searched
for transcendence through engagement with social reality and
the
natural environment. He was also enthralled by the mysterious
pageant
of universal transformation. Such themes as the equivalence of
objective and subjective viewpoints, the Tao as a ceaseless
alternation
between change and constancy, the affirmation ofhappiness in
this life,
equanimity toward fate, and unflagging curiosity about the
natural
world pervade his prolific writings. Su's shih poems alone
number
almost 2,8oo, of which those containing perceptions of Nature
and his
philosophical views have been the most widely read. His tz'u
poems,
numbering about 3 50, expanded the range of content in this
genre and
are considered innovative examples of an attitude of "heroic
abandon"
(hao1ang). One of the Eight Masters ofT'ang and Sung Prose, Su
was
further canonized by the literary tradition as the personification
of the
Northern Sung zeitgeist, an expansive, optimistic personality
who later
was celebrated in drama, painting, and the decorative arts.
As a travel writer Su employed a variety of forms such as
letters, ju
rhapsodies, travel records, random notes, and prefaces. His two
pieces
on Red Cliff were written during his exile in Huang Prefecture.
The
first is perhaps the best-known work of Chinese travel writing.
In it,
Su Shih achieved an optimistic solution to a lyric vision
imperiled by an
awareness of tragic history. His mood shifted in the second
piece to a
sober recognition of Nature's awesome power and the limits
ofhuman
ambition. Yet even here he concluded with an affirmation of the
possibility of transcendence. Together, these pieces became
monuments
of Chinese literature and art, establishing the place as a literary
shrine.
Red Cliff I "ff.r~5! ~ (1082)
In the fall of the year jen-hsii in the seventh month on the day
after the
moon had reached its height [August 12, 1082], I traveled in a
boat
with some guests to the foot of Red Cliff. 1 A light wind wafted
by, and
not a ripple was stirred. I poured wine for my guests as we
chanted the
poem about the bright moon and sang the song about the
graceful
186 SU SHIH
maiden. 2 Before long, the moon appeared over East Mountain
and
lingered by the constellations Dipper and Ox. 3 White dew
extended
over the Long River; the water's gleam mingled with the sky.
We let
this reed of a boat follow its course as it traversed an expanse
of
myriad ch'ing. I felt boundless, as if gliding through the void
not know-
ing where I might land; I felt like I was soaring about, having
left the
world behind to stand alone as I sprouted wings to become a
Transcen-
dent.
Then we drank more wine and reached the height of joy. I beat
out
a rhythm against the side of the boat and sang:
Cassia-wood oars,
Magnolia-wood rudder,
Stroke the moon's pure reflection
As we glide upstream on its shimmering light.
Ever distant, the object of my longings.
I gaze at the beautiful one
In a faraway corner ofHeaven.4
One of the guests could play the flute and accompanied my
song. 5
Yet his sounds-"wu-wu"-were plaintive, yearning, weeping,
accus-
ing. The lingering notes meandered through the air, drawn out
like
silken threads. They would have aroused a submerged chiao-
dragon to
whirl around in the cavernous depths, and caused a widow to
weep in
her lonely boat.
I was saddened. Straightening my clothes, I sat up and asked my
guest, "Why are you playing this way?" He replied,
" 'The moon is bright, stars are few
Crows and magpies are flying south. '6
"Isn't this from the poem by Ts'ao Ts'ao? Westward is Hsia-
k'ou; to
the east lies Wu-ch'ang.7 The mountains and the river encircle
one
another; how dense the viridian growth! Yet, is this not the
place
where Ts'ao was trapped by Chou Yii?8 He had just conquered
Ching-chou and sailed down to Chiang-ling9 as he followed the
course
of the river eastward. His fleet stretched bow to stern for a
thousand li;
his banners and flags blotted out the sky. As he drank wine by
the bank
of the river, he lay down his lance and composed this poem.
Indeed, he
dominated his age, yet where is he now? And what about you
and me,
SU SHIH 187
conversing here by the riverbank like a fisherman and a
woodcutter,
joined by fish and shrimp with the deer as our companions? We
ride on
a boat no bigger than a leaf as we drink to each other out of
simple
gourds. We exist no longer than mayflies between Heaven and
Earth,
and are of no more consequence than a kernel in the vast ocean.
I grieve
that my life is but a moment and envy the Long River's endless
flow. If
only I could grasp hold of a flying Transcendent and wander
with him
through the Heavens to embrace the bright moon and live
forever. But
I realize this cannot be, so I confide these lingering sounds to
the sad
autumn wind."
I said, "Do you really understand the water and the moon? Here,
it
flows by yet never leaves us; over there, it waxes and wanes
without
growing or shrinking. If you look at things as changing, then
Heaven
and Earth do not last for even the blink of an eye. If you look at
them
as unchanging, then I along with everything am eternal. So why
be en-
vious? Moreover, each thing within Heaven and Earth has its
master. If
I did not possess it, then I would not take even a hair of it.
However,
the pure wind over the river becomes sound when our ears
capture it,
and the bright moon between the mountains takes on form when
our
eyes encounter it. There is no prohibition against our acquiring
them,
and we can use them without ever consuming them. They are
from the
inexhaustible treasury of the Creator-of-Things, which you and
I can
enjoy together."
My guest became happy and laughed. We washed out the cups
and
drank again. Soon the food was gone, and the cups and plates
were
strewn about. We lay down in the boat, leaning against each
other for
pillows, unaware that it was becoming light in the east.
Red Cliff II 1~*~~ (1082)
In the tenth month of the same year on the day the moon
reached its
height [November 7], I walked from the Snow Lodge back
toward
Lin-kao. 1 Two guests accompanied me as we crossed over Yell
ow Clay
Slope. Frost and dew had already fallen; the leaves had all
dropped off
from the trees. Our shadows lay on the ground as we gazed up at
the
bright moon. We looked around us, delighted by the scene, and
sang
songs for each other as we walked along.
After a while I sighed, "I have guests but no wine, and even if I
had
wine, there is no food to go along with it. The moon is white,
the
wind, gentle. But how can we enjoy such a fine evening?" One
of the
188 SU SHIH
guests replied, "Today at twilight, I cast a net and caught a fish
with
a large mouth and fine scales. It resembles a Pine River perch. 2
But
where can we obtain some wine?" I went back and discussed
this with
my wife, who said, "There are two gallons of wine which I have
been
keeping for some time in case you should ever need it."
So we took along the wine and the fish and traveled once again
to
the foot of Red Cliff. The river flowed vociferously, the cleaved
banks
rose a thousand ch'ih. The mountain was high, the moon small.
The
water level had fallen, rocks protruded. How long had it been
since my
last visit? The scene was no longer recognizable! I lifted up my
robe and
alighted. I made my way among sharp crags, parting the
overgrowth
to crouch on rocks shaped like tigers and leopards and to climb
up trees
twisted like horned dragons. I pulled myself up to the
precarious nests
of falcons and peered down at the hidden palace of the river god
P'ing
1. 3 My two guests were unable to follow me this far. I
suddenly let out
a sharp cry. The plants and trees were startled and shook;
mountains
resounded, valleys echoed. Winds arose, and the water became
agi-
tated. For my part, I became hushed and melancholy, then awed
and
fearful. Then I began to tremble so that I could no longer
remain there.
I returned, got back on board, and had the boat steered into the
main-
stream. We let it drift until it came to rest there.
By then it was toward midnight. All around us it was deathly si-
lent. Suddenly, a solitary crane came toward us across the river
from
the east. Its wings traced cartwheels in the air. It seemed
dressed in a
white jacket over a black gown, and let out a long, piercing cry-
"chia"-as it swept past our boat and headed west.
A short while later the guests left, and I fell asleep. I dreamed
of
two Taoists clothed in feathers, fluttering about. 4 As they
passed by
Lin-kao, they greeted me and asked, "Did you enjoy your
journey to
Red Cliff?" When I asked their names, they looked down
without
answering. "Oh! Now I understand! Last night, was it not you
who
called out as you flew by?" The Taoists looked back at me and
laughed.
And then I suddenly awakened. I opened the door and looked
outside
but saw no trace of them. 5
Stone Bells Mountain ;Gjj:J.dC. (1084)
In 1084, Su Shih was given a slight promotion and transferred
from
Huang Prefecture to Ju Prefecture. He traveled to his new post
by boat
along the Long River together with his son, Su Mai (1059-?),
stopping
25
Fan Ch'eng-ta (1126-1193)
~,. ...; ...l-
~~ nx.,. ~
Fan Ch'eng-ta, from P'ing-chiang, Wu-chiin (modern Su-chou,
Chiang-su), was born into an official family. At the age of
seventeen,
he was identified as a promising young talent and asked to
submit
poetry to the Ministry of Rites. In I I 54, he became a
Metropolitan
Graduate and, two years later, began serving in local posts. Fan
was a
dedicated Confucian official concerned with the welfare of the
people,
the military strengthening of the state, and the recovery of the
north
from the Chin dynasty. By 1166 he had quickly risen to the
position of
vice-director in the Ministry of Personnel, causing political
opponents
to claim that he had been promoted above his rank; he was
therefore
dismissed and sent home. After two years in retirement, he
returned to
office, gaining the confidence of the Emperor Hsiao-tsung (r. I
I62-
ll 89) as a member of the irredentist faction. He successfully
carried out
a diplomatic mission to the Chin in I I70, which resulted in the
first of
his travel diaries, Grasping the Carriage Reins (Lan-p'ei lu),
along with a
cycle of seventy-two poems on the events of this journey. He
subsequently lost power at court for opposing a favorite of the
emperor
and again retired in I I7I. Fan returned to public life in I I 73 to
serve in
Kuang-hsi; he recorded his investigations of the area around
Kuei-lin in
a local gazetteer and in another travel diary, Riding in the Luan-
bird
Chariot (Ts'an-luan lu, II73). The following year he served as
military
commissioner in Szu-ch'uan, where he employed Lu Yu.
Returning to
the capital in 1177, Fan took over the Ministry ofRites and, in
II78,
became Examination Administrator and Participant in
Determining
Government Matters, an important policymaking position. A
few
months later he was again impeached by a jealous censor. After
213
Fig. 34·
Sung Hsii (1 525- ?), Eyebrows Mou11tai11 After a
Snowfall (1605}. N anking Museum, Nanking .
FAN CH'ENG-TA 215
returning to government in I I So for one final period of service,
he
retired in n83 owing to ill health; he lived on at Stone Lake
(Shih-hu)
in the Su-chou area for another ten years.
Later canonized as one of the Four Masters of Southern Sung
poetry, Fan worked largely in the field-and-garden genre. He
brought
to its tradition of reclusiveness, assertion of moral purity, and
transcendental longings a thorough realism, conveyed through
objective observations about moral and social life in the
countryside.
Some poems have a quality of egoless impersonality and sudden
shifts
in perspective, reflecting his interest in Ch'an Buddhism. His
monumental Gazetteer of Wu-chiin (Wu-chiin chih, I I92-I I93)
was
considered a model work. In his lyric travel records, he was
influenced
by the descriptive style of Liu Tsung-yiian and the
philosophical
attitudes of Su Shih, particularly in two accounts of his outings
on
Stone Lake. Fan was also regarded as an outstanding
calligrapher.
Diary of a Boat Trip to Wu (Wu-ch'uan lu) was written
following
Fan Ch'eng-ta's service in Szu-ch'uan. InJune II77, he set out on
his
return to Hang-chou at a leisurely pace that enabled him to stop
at
scenic places along the river route. The following selection
describes
the IO, I65-foot Eyebrows Mountain (0-mei-shan), located in
modern
0-mei District, Szu-ch'uan. One of the four sacred mountains of
Buddhism in China, its patron being the Bodhisattva
Samantabhadra, it
has been a site of religious pilgrimage since the T'ang. Even
earlier,
during the Eastern Chin, the calligrapher Wang Hsi-chih had
viewed it
from a nearby mountain and praised its beauty. Fan moored his
boat at
Chia Prefecture (modern Le-shan, Szu-ch'uan) and spent three
days
making the seventeen mile ascent to the summit, where pilgrims
and
sightseers could visit an ancient shrine and view "Buddha's
Halo." His
descriptive style is clear and reportorial, revealing his curiosity
about
the observable world and his interest in "the classification of
things";
some of his explanations of natural phenomena, though, would
be
considered unscientific today.
From Diary of a Boat Trip to Wu: Eyebrows Mountain
~4ltr~:"'lt.vQ J4 (1177)
On the day i-wei [July 24, 1177], the sky cleared after a
snowfall ....
We passed New Station, Eighty-four Slopes, and Sala Plateau. 1
The
wood and leaves of the sa/a-tree resemble the hai-t'ung, and it is
also like
the yang-mei. 2 Its flowers are red and white, blossoming in
spring and
216 FAN CH'ENG-TA
summer. It grows only on this mountain. I saw them as soon as I
climbed halfway up, but when I reached this point, they covered
the
whole mountain. In general, all the plants, trees, birds, and
insects on
Greater Eyebrow Peak differ from those found in the world
below.
Previously, I had only heard descriptions of them; now I have
been able
to investigate them for myself. I came in the last month of
summer. 3
Several days before, there was a heavy snowfall, and there were
still
fresh traces of it on the tree leaves. Among the rare plants, there
is one
that resembles the Eight Transcendents hydrangea, except that it
is a
deep purple. Another is like the morning glory, but several
times
larger. Yet another resembles smartweed but is a pale green. I
have
heard that rare flowers are especially plentiful in spring, but at
this sea-
son it is cold on the mountain and few can be seen. As for rare
herbs,
there are so many I could not enumerate them all. The mountain
is
high and windy, so trees cannot grow tall. Their branches all
hang
downward. Old moss clings to the trees like disheveled hair,
hanging
down several tens of feet and touching the ground. There is also
the
pagoda pine, shaped like a fir but with leaves that are round and
small.
It, too, cannot attain great height but grows erect in stages, like
a pa-
goda. They are especially plentiful on the summit. Furthermore,
there
are no birds at all, probably owing to the mountain's elevation,
for they
cannot fly this high.
From Sala Plateau I passed the Pavilion for Contemplating
Buddha,
Soft-Grass Plateau, and the Stream for Cleansing Feet before
finally
arriving at the Temple of the Brilliant Image on the summit.
Though it
contains several tens of wooden chambers, no one lives there. In
the
middle is a small chapel dedicated to the Bodhisattva
Samantabhadra. 4 I
began the climb at the beginning of the hours of mao [5 :oo-
7:00 A.M.];
now, it was already past shen [3:oo-s:oo P.M.]. At first I wore
summer
linen, but it gradually grew colder as I ascended. At Eighty-four
Slopes, it suddenly became quite cold. And when I reached the
sum-
mit, I had to quickly don a double layer of silk-padded clothes
as well
as a woolen gown and a camel-hair jacket. This exhausted the
clothing
I had brought along in the trunks. I wrapped a turban around my
head
in several layers and put on felt boots. Still, it was shiveringly
cold,
quite unbearable. So I burned charcoal in a brazier, which I
clutched as
I sat up straight. There is a spring on the summit, but the water
cannot
boil rice. The kernels remain hard like grains of sand. I knew
that water
from ancient ice and snow cannot be used to cook with, 5 so I
had a jar
of water brought along from down below, and this was enough
to sus-
tain me.
FAN CH'ENG-TA 217
A while passed, then I braved the cold and went up over the
Bridge
of the Celestial Transcendent to Brilliance Cliff, where I lit
some
incense. The chapel there is covered with a roofing of bark. The
Vice-Grand Councillor Wang Chan-shu6 once had the roof tiled,
but
the snow and frost seeped in and within a year the tiles had all
cracked.
Later it was reroofed with bark that at least lasts for two to
three
years. Someone said to me, "Buddha's Halo always appears at
the hours
of wu [u:oo A.M.-I:oo P.M.]. Now it is past shen [3:oo-s:oo
P.M.]. We
had better return to our lodgings and come again tomorrow."
While
we were hesitating, suddenly clouds arose below the cliff from a
valley
to the side, just where Thunder Cave Mountain is located. The
clouds
paraded by vigorously like an honor guard. When they
encountered the
cliff, they paused for a short while. From the top of the clouds,
a grand
halo appeared containing several rings of various colors. I stood
exactly
opposite it and saw an inky shadow in its center, like a
Transcendent or
a sage astride an elephant. 7 In the time it would take to drink a
cup of
tea, the halo vanished, while beside it appeared another halo
just like
the one before. It, too, vanished after a while. From the clouds
there
then appeared two rays of golden light, which extended along
the waist
of the cliff. People call it the "Lesser Manifestation." By sunset,
the
clouds had all dispersed, and the surrounding mountains became
quite
tranquil. By the second night watch [9:oo-u:oo P.M.], lights
appeared
all over below the cliff. When viewed from a distance, they
seemed to
number in the many hundreds, perhaps even a thousand. At
night, the
cold was intense; I could not stand outside for long.
The next day, ping-shen [July 25], I again ascended Brilliance
Cliff
for the view. Behind the cliff were the many layers of the
Mount Min
range. Slightly to the north was Tiled House Mountain, located
in Y a
Prefecture. 8 A bit to the south was Greater Tiled House
Mountain,
close to the area of Nan-chao. 9 Its shape looked just like a one-
room
house with a tiled roof. There was also a halo at Lesser Tiled
Roof
Mountain, known as the "Manifestation of Self-Enlightenment. "
10 Be-
hind these mountains are the Snowy Mountains of the Western
Re-
gion.11 Lofty, rugged, carved, sliced; scores, perhaps a hundred
peaks in
all. When the rising sun first illuminates them, the snow
glistens like
shiny silver, shimmering in the light of the dawn. From
antiquity to
the present, this snow has never melted. These mountains
extend all
the way to the land of India and to tributary kingdoms along the
border
for a distance of I don't know how many thousands of li. It
looks
like it is spread out on a table before one. This spectacular,
unique,
unsurpassable view was truly the crowning one of my entire
life.
218 FAN CH'ENG-TA
I returned to the chapel on the cliff to offer up a prayer. Soon, a
dense mist arose on all sides, blending everything into a single
white-
ness. A monk said to me, "This is the 'Silvery World."' After a
while,
a heavy rain fell and the mist dispersed. The monk said, "This is
the
'Rain That Cleanses the Cliff.' 'Buddha's Halo' is about to
appear."
Flossy clouds once again spread out below the cliff, billowing
upward
until they reached only several tens of feet below the top. The
clouds
smoothed themselves out like a floor of jade. There was a
sudden rain,
and droplets flew about. I looked down at the middle of the
cliff-
there was a large halo lying on top of the smooth clouds.
Encircling it
were three rings, each containing blue, yellow, red, and green
colors.
The center of the halo was empty, bright, dense, and clear. Each
ob-
server could see his form appear in the empty, bright area
without the
slightest degree of obscurity, just like a mirror. When one
raised one's
hands and moved one's legs, the reflection indicated this
without show-
ing anyone else's form. The monk said, "This is the 'Halo That
Captures
the Body.'" When this halo vanished, winds arose from the
mountains
in front and the clouds quickly drifted away.
From the midst of the wind and clouds appeared yet another
large
halo. It stretched across several mountains and contained many
unusual
hues, all gathered together in a multicolored light. Peaks,
plants, and
trees were so fresh, gorgeous, brilliant, and glittering that I
couldn't
look at them directly. When the clouds and mist dispersed, this
halo
remained to shine alone. People call it the "Pure Manifestation."
When
Buddha's Halo is about to appear, clouds must gather first,
forming
what is known as the "Flossy World." It is from out of these
clouds
that the halo appears. But when it appears without the help of
clouds, it
is called a "Pure Manifestation" and is extremely rare. After the
time it
would take to have a meal, the halo gradually shifted westward
past the
mountain. I glanced to the left above Thunder Cave Mountain
and
again saw a halo just like the one before, only slightly smaller.
After a
moment it, too, flew off beyond the mountain, moving over
toward
the plateau, where it hovered just opposite the cliff. Its colors
had all
changed, and it became the "Golden Bridge," similar to the
Rainbow
Bridge over the Wu River12 except that the two ends of this
"bridge"
were supported by purple clouds. Between the hours of wu [I I
:oo
A.M.-I:oo P.M.] and wei [1:oo-3:oo P.M.] the clouds all
disappeared, and
this is called "The Final Scene at the Cliff." Only Golden
Bridge re-
mained visible until after yu [s:oo-7:oo P.M.], when it vanished.
13
26
Chu Hsi (11J0-12oo)
Chu Hsi was the major formulator ofNeo-Confucianism, which
absorbed concepts of metaphysics and consciousness from
Buddhism
and Taoism into traditional Confucian ethics. His
comprehensive views
on the classics were accepted as orthodox thought by the end of
the
Southern Sung and became the basis of the examination system
when it
was reinstated in the late Yiian. During the Ming and Ch'ing
dynasties,
he was canonized as a Sage and sacrificed to in temples along
with
Confucius and Mencius. His career, however, followed a pattern
similar to that of many officials: public service in a variety of
offices
alternating with periods of political disfavor. While he lived,
there was
little indication of the extraordinary veneration he was to be
accorded
throughout the later Chinese empire.
Chu Hsi grew up in Ch'ung-an, Chien-yang, in what is today Fu-
chien, in an official family originally from Chiang-hsi. His
father was
demoted for opposing Ch'in Kuei's appeasement policies and
died
when Chu Hsi was fourteen; subsequently, Chu Hsi continued to
espouse his father's patriotic views and suffered similar
punishments
during his own career. He earned the Metropolitan Graduate
degree in
1 148 and began to serve in local positions. Meanwhile, he
attracted
disciples and developed his own program of Confucian
education. In
1163, under Emperor Hsiao-tsung, he was granted an audience
and
argued for war against the Chin. Though appointed to a number
of
positions both in the provinces and in the capital, he often
refused to
accept appointments because of policy differences, or served
only
briefly before retiring or being demoted. During a fifty-year
career, he
spent only nine years in office and about forty days at court.
His
~~
influence was greater through the educational institutions he
sponsored. 219
Fig. 35·
Portrait ofChu Hsi. (n.d .) National Pa lace
Museum , Taipei.
CHU HSI 221
He helped to restore the White Deer Cave Academy in I I79
while
serving in Chiang-hsi and the Academy at the Foothills of the
Sacred
Mount in I I94 while serving as military commissioner in Hu-
nan. By
the end of his career in I I95 he had become an edict attendant
in the
Han-lin Academy, but, after angering the powerful official Han
T'o-
chou, he was finally impeached. His remaining years were spent
back
in Chien-yang writing and teaching.
Chu Hsi's aesthetics asserted the absolute identity ofliterature
and
the Tao, in contrast to more conventional formulations, which
saw
writing as but an expression or vehicle of the Tao. For Chu Hsi,
they
were one and the same, unified through the moral cultivation of
the
individual. Similarly, he espoused the view, stated in the "Mao
Preface" to The Book of Poetry, that poetry was simply the
expression of
the moral will. His poems, for which he achieved some note,
conveyed
an archaistic temperament, employing few allusions or metrical
intricacies in favor of direct, uncomplicated emotions and
objective
observations of the world. His prose, as might be expected, was
largely
didactic and pragmatic. Among the more influential texts
associated
with him is the Collected Sayings of Master Chu (Chu-tzu yii-
lei), which
transmitted his remarks on philosophy and literature. It came to
be
looked upon as a literary model for its inclusion of colloquial
elements
that captured a sense of actual speech.
The following travel piece is undated, but it must have been
written
before 1185, when one ofhis traveling companions, Liu P'ing-fu,
died.
That it has been often anthologized is probably due to the
prestige of
the writer, for it is a conventional, though well-wrought, travel
account. Like many travel narratives, it was originally written
in
conjunction with poems. Chu Hsi represented his experience of
a
journey as a linear progress through a world of concrete
appearances
and sensations with only brief autobiographical and lyric
elements. The
piece reveals a restrained imagination focused on "the
classification of
things," recording immediate observations of the environment.
The Mountain a Hundred Chang High a~ J.i ~C.
After ascending the Mountain a Hundred Chang High 1 for
about a
mile, I peered down to the right at a deep valley and braced
myself on
the left against an overhanging cliff. Stones had been stacked to
form
stairs. I climbed all ten or so of them. The scenic beauty of the
moun-
tain began from here.
222 CHU HSI
I followed more stairs eastward and encountered a small stream;
a
rock bridge spanned it. Everywhere were aged vines and ancient
trees.
Although it was the height of summer, it was not hot, even at
noon-
time. The water was completely clear and deep. It splashed
down from
higher up with splattering sounds-" chien-chien." I crossed the
rock
bridge, followed alongside two cliffs, winding my way higher
until I
reached the outer gate of a temple. It was a small building with
three
rooms, hardly capable of accommodating ten or so people. Still,
from
the front it surveyed the stream below; in back, it faced a rock
pond.
Wind comes wafting through two gorges all day long without
respite.
Inside the gate, one passes over a pond by another rock bridge.
Cross-
ing it and turning northward, I climbed up many stone steps to
arrive
at the temple. The temple itself was an old building of several
rooms-
small, low, cramped, and narrow-not much to look at. Only its
west-
ern pavilion offered a scenic view. Water flows out from the
valley to
the west, then through a fissure in the rock, and shoots out from
be-
neath the pavilion. Southward, it meets the stream from the
valley to
the east and flows into the pond. When it leaves the pond, it
becomes
the small stream mentioned earlier. The pavilion occupies a
position
upstream, just where the onrushing water and steep rocks
confront
each other, a most enjoyable site. But a wall was built behind it,
so
there is nothing further to see. I spent the night upstairs in the
pavilion
alone. Below my bed was the gurgling of water-"chan-chan"-
throughout the evening. After a long while, the sounds became
in-
creasingly melancholy; it was all quite charming.
Exiting through the temple gate eastward ten or so paces, I
came
upon a rock terrace. Below, it extended to a steep cliff, which
was deep,
dark, dangerous, and inaccessible. I gazed to the southeast
through
a dense grove and saw a cascade from a rock cave in front shoot
out
into the air and then drop down for several tens of feet. The
foam was
like scattering pearls and exhaled mist: as the sunlight
illuminated it,
the luster was so striking that I couldn't look at it directly. The
terrace
occupies an open spot on the southwest of the mountain. In
front it
greets Reed Peak Mountain, 2 whose single peak soars
handsomely
while for several hundred li about peaks and pinnacles, high and
low,
one by one, are displayed before one's eyes.
As the sun drew near to the mountains on the west, its twilight
rays
glowed across the sky. Purple and emerald green intermingled-
an in-
describable sight. When I arose at dawn and looked down
below, white
clouds formed a river rising and falling like waves in the ocean.
All the
mountains, far and near, protruded through the middle. They
seemed
CHU HSI 223
to fly and float, back and forth, now surging, now engulfed. In
but a
short while, a myriad transformations occurred. East of the
terrace, the
path ended. Local people have cut stairs into the rock in order
to pass.
They have placed a shrine to the east of it. In times of drought,
they
offer up prayers to it. Those who are frightened by the
dangerous
steepness dare not cross, though beyond this point there is
nothing
more worth viewing on the mountain anyway.
I traveled here with Liu Ch'ung-fu, Liu P'ing-fu, 3 Lii Shu-
ching,
and my cousin Hsii Chou-pin. We all wrote poems to mark the
scenic
spots. I also wrote this description of the sequence of sights.
Those
most worth viewing are the stone stairs, the small stream, the
temple
gate, the rock terrace, the West Pavilion, and the cascade.
Because these
places are so distinctive, I composed a short poem to record
each one
and offer them to my fellow travelers as well as to those who
would
like to journey here but cannot.
RECORDED ON THE-- DAY, IN THE __ MONTH OF THE--
YEAR4
COMP 3004 – cuACS Deliverable #2
Due: Tuesday, March 5, 2019 at 8:30 AM (morning)
Algorithm Design Document
You will design your Animal-Client Matching (ACM)
algorithm, as specified in the project description posted
in cuLearn, and you will provide a PDF document that describes
it. Your document will define, explain, and
justify the following:
• a minimum of twelve (12) separate and original non-physical
attributes to be used by your algorithm
for matching animals available for adoption with the clients
who wish to adopt them
NOTE: a large proportion of binary attributes, such as those
with yes/no values, will result in an
algorithm that is insufficiently original and complex, and will
likely earn a failing grade
• the valid range of values for each attribute
• a unique set of rules for matching together animal and client
profiles, based on the attributes
contained in those profiles; the rules must use all the attributes
that you define, including a client’s
own attributes and their matching preferences
• a description of the algorithm detailing how the rules are used
to compute the optimal set of matches
Your algorithm will be evaluated based on the variety,
originality, complexity, and appropriateness of its
matching rules and attributes.
Algorithm Design Presentation
Presentations discussing each team’s ACM algorithm will take
place in class on March 5, 7, 12, 14, and
possibly into March 19. The projected date each team’s
presentation will be decided a few days in advance,
but the exact time will be random. All teams are expected to be
in the classroom at the start of their
presentation day. Each team will be given five (5) minutes to
explain and justify their algorithm, including
their choice of attributes and matching rules.
Each team will submit their presentation slides in cuLearn
before the Deliverable #2 due date. Modifications
to the presentation slides after the due date and time will be
disallowed.
Feature Implementation
You will implement the following cuACS features, as specified
in the project description posted in cuLearn:
• Staff/client feature: View all animals (listing and detailed
information)
• Staff feature: Add animal, with all the animal profile
information required by the ACM
algorithm
• Staff feature: View all clients (listing and detailed
information)
• Staff feature: Add client, with the basic contact information
Your submission must contain a minimum of 25 different
animal profiles and 5 client profiles in persistent
storage. These profiles must be loaded into memory when the
program launches. The animal profiles must
include values for all physical attributes, as well as all the
attributes defined for the ACM algorithm. The client
profiles must include the basic contact information.
COMP 3004 -- Winter 2019 cuACS -- Deliverable #2 1/2
Grading
Grading breakdown:
• Algorithm design document: 40%
• Algorithm design presentation: 20%
• Feature implementation: 40%
View all animals (staff/client) 10%
Add animal 10%
View all clients 10%
Add client 10%
Format
Documentation deliverables must be submitted as a PDF
document. They must be typed and legible,
and they must be professional documents, including a cover
page, page numbers, table of contents,
table of figures, section numbers and names, etc. All diagrams
and tables must be introduced and
explained in the text. All the text must be in your own words.
Copying or pasting from any sources,
even cited ones, is strictly disallowed. Documents that do not
conform to these specifications will not be
graded.
Coding deliverables must be delivered as a single tar file
consisting of all source code, data files, and
configuration scripts, as well as installation, build, and launch
instructions in a readme file. Do not
provide object files and project executables as part of your
submission. Coding submissions that cannot
be downloaded into a fresh directory and un-tar’ed, then
successfully built with a single command in the
course VM, and successfully launched with a single command in
the course VM, will not be graded.
Submissions without a readme file to explain installation, build,
and launch instructions will not be
graded.
COMP 3004 -- Winter 2019 cuACS -- Deliverable #2 2/2
./addnewanimalform.cpp
#include "addnewanimalform.h"
#include "iostream"
AddNewAnimalForm::AddNewAnimalForm(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
nameBox = new QLineEdit();
speciesBox = new QLineEdit();
ageBox = new QLineEdit();
ageBox->setValidator(new QIntValidator());//Only ints
allowed
weightBox = new QLineEdit();
weightBox->setValidator(new QIntValidator());//Only ints
allowed
sizeBox = new QLineEdit();
colorBox = new QLineEdit();
genderBox = new QComboBox(); //Set up the options for the
drop-down menu
QStringList genderOptions = QStringList();
genderOptions << "Male" << "Female";
genderBox->addItems(genderOptions);
//Now that we've created all the input fields, we add them to
the form
ui->addForm->addRow(QString("Name:"), nameBox);
ui->addForm->addRow(QString("Species:"), speciesBox);
ui->addForm->addRow(QString("Gender:"), genderBox);
ui->addForm->addRow(QString("Color:"), colorBox);
ui->addForm->addRow(QString("Age:"), ageBox);
ui->addForm->addRow(QString("Weight(g):"), weightBox);
ui->addForm->addRow(QString("Size:"), sizeBox);
}
AddNewAnimalForm::~AddNewAnimalForm()
{
delete nameBox;
delete speciesBox;
delete genderBox;
delete colorBox;
delete ageBox;
delete weightBox;
delete sizeBox;
delete ui;
}
void AddNewAnimalForm::accept()
{
std::string name = nameBox->text().toStdString();
std::string species = speciesBox->text().toStdString();
std::string color = colorBox->text().toStdString();
std::string age = ageBox->text().toStdString();
std::string weight = weightBox->text().toStdString();
std::string gender = genderBox->currentText().toStdString();
std::string size = sizeBox->text().toStdString();
//If all of the fields hold a value, we create a new animal and
emit the addNew signal
if (!name.empty() && !species.empty() && !color.empty()
&& !age.empty() && !weight.empty() && !gender.empty() &&
!size.empty()) {
Animal * newAnimal = new Animal(name, species, color,
std::stoi(age), std::stoi(weight), gender, size);
emit addNew(newAnimal);
}
//Either way we close the panel
emit closePane();
close();
}
void AddNewAnimalForm::reject()
{
emit closePane();
close();
}
./addnewanimalform.h
#ifndef ADDNEWANIMALFORM_H
#define ADDNEWANIMALFORM_H
#include <QWidget>
#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include "ui_addnewanimalform.h"
#include "animal.h"
//This is the class for the form that pops down when you click
File > Add Animal. addnewanimalform.ui is the .ui file which
corresponds to it.
class AddNewAnimalForm : public QDialog
{
Q_OBJECT
public:
explicit AddNewAnimalForm(QWidget *parent = nullptr);
~AddNewAnimalForm();
signals:
void addNew(Animal * animal);//Sent when the user hits
'OK' and successfully adds an animal to the program
void closePane();//Sent when the user closes the form by any
means
public slots:
void accept(); //Received when the user hits the OK button
void reject(); //Received when the user hits the Cancel button
private:
Ui::Dialog *ui;
//We add these widgets to the FormLayout located in ui, and
get user input from them.
QLineEdit * nameBox;
QLineEdit * ageBox;
QLineEdit * colorBox;
QLineEdit * weightBox;
QLineEdit * sizeBox;
QLineEdit * speciesBox;
QComboBox * genderBox;
};
#endif // ADDNEWANIMALFORM_H
./addnewanimalform.ui
Dialog
0
0
400
300
Dialog
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::Ok
buttonBox
rejected()
Dialog
reject()
316
260
286
274
buttonBox
accepted()
Dialog
accept()
248
254
157
274
./animal.cpp
#include "animal.h"
Animal::Animal(int id, std::string &name, std::string &species,
std::string &color, int age, int weight, std::string &gender,
std::string &size):
id(id),
name(name),
species(species),
color(color),
age(age),
weight(weight),
gender(gender),
size(size)
{
}
//This constructor is for brand-new animals, for whom we don't
have a database ID yet. We set the id to -1 so that we know to
assign the proper id later.
Animal::Animal(std::string &name, std::string &species,
std::string &color, int age, int weight, std::string &gender,
std::string &size):
Animal(-1, name, species, color, age, weight, gender, size)
{
}
std::string Animal::getName()
{
return name;
}
std::string Animal::getSpecies()
{
return species;
}
std::string Animal::getColor()
{
return color;
}
int Animal::getAge()
{
return age;
}
int Animal::getWeight()
{
return weight;
}
std::string Animal::getGender()
{
return gender;
}
std::string Animal::getSize()
{
return size;
}
void Animal::setName(const std::string &value)
{
name = value;
}
void Animal::setSpecies(const std::string &value)
{
species = value;
}
void Animal::setColor(const std::string &value)
{
color = value;
}
void Animal::setAge(int value)
{
age = value;
}
void Animal::setWeight(int value)
{
weight = value;
}
void Animal::setGender(const std::string &value)
{
gender = value;
}
void Animal::setSize(const std::string &value)
{
size = value;
}
int Animal::getId() const
{
return id;
}
void Animal::setId(int value)
{
//We can only set the ID if the current ID is less than 0
(meaning, is not a valid database ID)
if (id < 0) {
id = value;
}
}
./Animal.db
./animal.h
#ifndef ANIMAL_H
#define ANIMAL_H
#include<string>
//A class representing a generic animal. Will probably see
significant restructuring as the project continues. Right now,
just a container for attributes.
class Animal
{
public:
Animal(int id, std::string & name, std::string & species,
std::string & color, int age, int weight, std::string & gender,
std::string & size);
Animal(std::string & name, std::string & species, std::string
& color, int age, int weight, std::string & gender, std::string &
size);
std::string getName();
std::string getSpecies();
std::string getColor();
int getAge();
int getWeight();
std::string getGender();
std::string getSize();
void setName(const std::string &value);
void setSpecies(const std::string &value);
void setColor(const std::string &value);
void setAge(int value);
void setWeight(int value);
void setGender(const std::string &value);
void setSize(const std::string &value);
int getId() const;
void setId(int value);
private:
std::string name;
std::string species;
std::string color;
int age;
int weight;
std::string gender;
std::string size;
int id;
};
#endif // ANIMAL_H
./animaltablemodel.cpp
#include "animaltablemodel.h"
AnimalTableModel::AnimalTableModel(QObject *parent)
{
storedParent = parent;
animals = std::vector<Animal *>();
}
AnimalTableModel::~AnimalTableModel()
{
foreach (Animal * animal, animals) {
delete animal;
}
}
int AnimalTableModel::rowCount(const QModelIndex &parent)
const
{
return animals.size();
}
int AnimalTableModel::columnCount(const QModelIndex
&parent) const
{
return 2;
}
QVariant AnimalTableModel::data(const QModelIndex &index,
int role) const
{
if (role == Qt::DisplayRole)
{
if (index.column() == 0) {
auto name = animals[index.row()]->getName().c_str();
return QString("%1").arg(name);
} else if (index.column() == 1) {
auto species = animals[index.row()]-
>getSpecies().c_str();
return QString("%1").arg(species);
}
}
return QVariant();
}
QVariant AnimalTableModel::headerData(int section,
Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole)
{
if (orientation == Qt::Horizontal) {
switch (section)
{
case 0:
return QString("Name");
case 1:
return QString("Species");
}
}
}
return QVariant();
}
void AnimalTableModel::addItem(Animal *item)
{
//If the animal's ID is less than or equal to zero, it is not yet
in the database, so we add it and retrieve the new ID#.
if (item->getId() <= 0) {
SqlHandler::addNew(item);
}
beginInsertRows(QModelIndex(), animals.size(),
animals.size());
animals.push_back(item);
insertRows(animals.size(), 1);
endInsertRows();
}
//Not currently used, database not supported, largely untested
void AnimalTableModel::removeItem(Animal *item)
{
int index = -1;
for (unsigned int i = 0; i < animals.size(); i++) {
if (animals[i]->getName() == item->getName()) {
index = i;
}
}
if (index < 0) {
return;
}
animals.erase(animals.begin() + index);
}
std::vector<Animal *> AnimalTableModel::getAnimals()
{
return animals;
}
./animaltablemodel.h
#ifndef ANIMALTABLEMODEL_H
#define ANIMALTABLEMODEL_H
#include <QAbstractTableModel>
#include "animal.h"
#include "sqlhandler.h"
#include <vector>
//The Model for the table containing the animals. Displays the
name and species, and stores the rest of the data for display
elsewhere
class AnimalTableModel : public QAbstractTableModel
{
Q_OBJECT
public:
AnimalTableModel(QObject *parent);
~AnimalTableModel();
int rowCount(const QModelIndex &parent = QModelIndex())
const ;
int columnCount(const QModelIndex &parent =
QModelIndex()) const;
QVariant data(const QModelIndex &index, int role =
Qt::DisplayRole) const; //Function which defines the output to
the table
QVariant headerData(int section, Qt::Orientation orientation,
int role) const;
void removeItem(Animal * item); //We have the capability to
remove objects from the table but it is not currently used and
does not remove from the database
std::vector<Animal *> getAnimals();
public slots:
void addItem(Animal * item); //Adds an animal to the table
and database
private:
std::vector<Animal *> animals; //A vector containing all of
the animals in the table
QObject *storedParent; //We store the parent of the model;
not currently used
};
#endif // ANIMALTABLEMODEL_H
./cuACS.pro
#-------------------------------------------------
#
# Project created by QtCreator 2019-02-08T23:09:20
#
#-------------------------------------------------
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = cuACS
TEMPLATE = app
# The following define makes your compiler emit warnings if
you use
# any feature of Qt which has been marked as deprecated (the
exact warnings
# depend on your compiler). Please consult the documentation
of the
# deprecated API in order to know how to port your code away
from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use
deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a
certain version of Qt.
#DEFINES +=
QT_DISABLE_DEPRECATED_BEFORE=0x060000 #
disables all the APIs deprecated before Qt 6.0.0
SOURCES += 
main.cpp 
mainwindow.cpp
animaltablemodel.cpp 
animal.cpp 
addnewanimalform.cpp 
sqlhandler.cpp
HEADERS += 
mainwindow.h 
animaltablemodel.h 
animal.h 
addnewanimalform.h 
sqlhandler.h
FORMS += 
mainwindow.ui 
addnewanimalform.ui
DISTFILES += 
Animal.db
./cuACS.pro.user
EnvironmentId
{c76633c0-7a82-4780-8688-cb14bec9d289}
ProjectExplorer.Project.ActiveTarget
0
ProjectExplorer.Project.EditorSettings
true
false
true
Cpp
CppGlobal
QmlJS
QmlJSGlobal
2
UTF-8
false
4
false
80
true
true
1
true
false
0
true
true
0
8
true
1
true
true
true
false
ProjectExplorer.Project.PluginSettings
ProjectExplorer.Project.Target.0
Desktop
Desktop
{d29fab11-7d8e-483c-ace2-f5f2564c9bb1}
0
0
0
/home/student/Desktop/FinalTemp/build-cuACS-Desktop-
Debug
true
qmake
QtProjectManager.QMakeBuildStep
true
false
false
false
true
Make
Qt4ProjectManager.MakeStep
-w
-r
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
-w
-r
true
clean
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Debug
Qt4ProjectManager.Qt4BuildConfiguration
2
true
/home/student/Desktop/FinalTemp/build-cuACS-Desktop-
Release
true
qmake
QtProjectManager.QMakeBuildStep
false
false
false
false
true
Make
Qt4ProjectManager.MakeStep
-w
-r
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
-w
-r
true
clean
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Release
Qt4ProjectManager.Qt4BuildConfiguration
0
true
/home/student/Desktop/FinalTemp/build-cuACS-Desktop-
Profile
true
qmake
QtProjectManager.QMakeBuildStep
true
false
true
false
true
Make
Qt4ProjectManager.MakeStep
-w
-r
false
2
Build
ProjectExplorer.BuildSteps.Build
true
Make
Qt4ProjectManager.MakeStep
-w
-r
true
clean
1
Clean
ProjectExplorer.BuildSteps.Clean
2
false
Profile
Qt4ProjectManager.Qt4BuildConfiguration
0
true
3
0
Deploy
ProjectExplorer.BuildSteps.Deploy
1
Deploy locally
ProjectExplorer.DefaultDeployConfiguration
1
false
false
1000
true
false
false
false
false
true
0.01
10
true
1
25
1
true
false
true
valgrind
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
cuACS
Qt4ProjectManager.Qt4RunConfiguration:/home/student/Deskto
p/FinalTemp/COMP3004Temp/cuACS.pro
true
cuACS.pro
false
/home/student/Desktop/FinalTemp/build-cuACS-Desktop-
Debug
3768
false
true
false
false
true
1
ProjectExplorer.Project.TargetCount
1
ProjectExplorer.Project.Updater.FileVersion
18
Version
18
./install
mkdir --parents -v /opt/cuACS
cp --verbose -uR Animal.db $_
chmod --recursive a+w /opt/cuACS
qmake
make
./main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
./mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("cuACS 0.01");
//Set up table
model = new AnimalTableModel(this);
ui->tableView->setModel(model);
ui->tableView-
>setSelectionBehavior(QAbstractItemView::SelectRows);
ui->tableView->horizontalHeader()-
>setSectionResizeMode(QHeaderView::Stretch);
ui->tableView-
>setSelectionMode(QAbstractItemView::SingleSelection);
std::vector<Animal *> database =
SqlHandler::fetchDatabase();
foreach(Animal * animal, database) {
model->addItem(animal);
}
//Set up details panel
detailsPanel = ui->animalDetails;
nameBox = new QLineEdit();
speciesBox = new QLineEdit();
ageBox = new QLineEdit();
ageBox->setValidator(new QIntValidator());
weightBox = new QLineEdit();
weightBox->setValidator(new QIntValidator());
sizeBox = new QLineEdit();
colorBox = new QLineEdit();
genderBox = new QComboBox();
QStringList genderOptions = QStringList();
genderOptions << "Male" << "Female";
genderBox->addItems(genderOptions);
//Add all the input fields to the form layout
detailsPanel->addRow(QString("Name:"), nameBox);
detailsPanel->addRow(QString("Species:"), speciesBox);
detailsPanel->addRow(QString("Gender:"), genderBox);
detailsPanel->addRow(QString("Color:"), colorBox);
detailsPanel->addRow(QString("Age:"), ageBox);
detailsPanel->addRow(QString("Weight(g):"), weightBox);
detailsPanel->addRow(QString("Size:"), sizeBox);
//Set up the selectionChanged signal
QItemSelectionModel *selectionModel= ui->tableView-
>selectionModel();
connect(selectionModel, SIGNAL(selectionChanged (const
QItemSelection &, const QItemSelection &)),
this, SLOT(selectionChangedSlot(const QItemSelection
&, const QItemSelection &)));
//Set up the signals for the details/editing box
connect(nameBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(speciesBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(ageBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(weightBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(sizeBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(colorBox, SIGNAL(editingFinished()), this,
SLOT(valueUpdatedSlot()));
connect(genderBox, SIGNAL(activated(int)), this,
SLOT(valueUpdatedSlot()));
//Now we hide all the input fields until a selection is made in
the table
nameBox->hide();
speciesBox->hide();
ageBox->hide();
weightBox->hide();
sizeBox->hide();
colorBox->hide();
genderBox->hide();
}
MainWindow::~MainWindow()
{
delete ui;
delete nameBox;
delete speciesBox;
delete genderBox;
delete colorBox;
delete ageBox;
delete weightBox;
delete sizeBox;
delete model;
delete detailsPanel;
delete docker;
}
void MainWindow::removeDocker()
{
docker->close();
}
void MainWindow::selectionChangedSlot(const QItemSelection
& /*newSelection*/, const QItemSelection & /*oldSelection*/)
{
nameBox->show();
speciesBox->show();
ageBox->show();
weightBox->show();
sizeBox->show();
colorBox->show();
genderBox->show();
const QModelIndex index = ui->tableView-
>selectionModel()->currentIndex();
currentAnimal = model->getAnimals()[index.row()];
nameBox->setText(QString(currentAnimal-
>getName().c_str()));
ageBox->setText(QString(std::to_string(currentAnimal-
>getAge()).c_str()));
speciesBox->setText(QString(currentAnimal-
>getSpecies().c_str()));
genderBox->setCurrentIndex(genderBox-
>findText(QString(currentAnimal->getGender().c_str())));
weightBox->setText(QString(std::to_string(currentAnimal-
>getWeight()).c_str()));
sizeBox->setText(QString(currentAnimal-
>getSize().c_str()));
colorBox->setText(QString(currentAnimal-
>getColor().c_str()));
}
void MainWindow::valueUpdatedSlot()
{
currentAnimal->setName(nameBox->text().toStdString());
currentAnimal->setSpecies(speciesBox-
>text().toStdString());
currentAnimal->setAge(std::stoi(ageBox-
>text().toStdString()));
currentAnimal->setColor(colorBox->text().toStdString());
currentAnimal->setWeight(std::stoi(weightBox-
>text().toStdString()));
currentAnimal->setGender(genderBox-
>currentText().toStdString());
currentAnimal->setSize(sizeBox->text().toStdString());
if (currentAnimal->getId() > 0) {
SqlHandler::updateItem(currentAnimal);
}
}
void MainWindow::on_actionAdd_triggered()
{
docker = new QDockWidget(QString("Add New"), this);
AddNewAnimalForm * form = new
AddNewAnimalForm(this);
docker->setWidget(form);
connect(form, SIGNAL(addNew(Animal *)), model,
SLOT(addItem(Animal*)));
connect(form, SIGNAL(closePane()), this,
SLOT(removeDocker()));
addDockWidget(Qt::TopDockWidgetArea, docker);
}
./mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLineEdit>
#include <QComboBox>
#include <QItemSelection>
#include <QInputDialog>
#include <QFormLayout>
#include <QDockWidget>
#include "animaltablemodel.h"
#include "addnewanimalform.h"
#include "sqlhandler.h"
//This class defines and controls the main window of the UI.
//The ui file corresponding to this class is mainwindow.ui
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
void removeDocker(); //Removes the docked widget (the add
animals widget) because it's no longer needed
private:
Ui::MainWindow *ui;
//These are the input fields on the right which allow the user
to edit the sleected animal
QComboBox * genderBox;
QLineEdit * nameBox;
QLineEdit * ageBox;
QLineEdit * speciesBox;
QLineEdit * colorBox;
QLineEdit * weightBox;
QLineEdit * sizeBox;
//The current animal selected in the table
Animal * currentAnimal;
//The table model
AnimalTableModel * model;
//The form layout containing the details/edit fields for the
selected animal
QFormLayout * detailsPanel;
//The widget for adding animals to the database
QDockWidget * docker;
private slots:
void selectionChangedSlot(const QItemSelection &
newSelection, const QItemSelection & oldSelection); //Received
when the selected item in the table changes
void valueUpdatedSlot(); //Received when the value in an
input field changes
void on_actionAdd_triggered(); //Received when File > Add
Animal is clicked on
};
#endif // MAINWINDOW_H
./mainwindow.ui
MainWindow
0
0
1224
800
MainWindow
0
0
1224
22
File
Add Animal
./README.md
# Carleton University Animal Care System
Created for Carleton University's COMP3004 course (taught by
Prof. Christine Laurendeau) by Peter MacDonald (100683150),
Ibiduneyitayo(101018199), and Nicholas Aubé(101032093)
## Installation
To install the software after extracting it from the .tar file,
simply run the following command in the directory:
```
sudo bash install
```
You will likely be prompted to input your administrator
password in order to run the install script with sudo.
Local files, such as the animal database, are installed to the
directory /opt/cuACS in your file system. If this directory
already contains files, they may be overwritten in this process.
## Running
To run the software, after installing, run the following command
from the same directory:
```
./cuACS
```
## Cleanup
To clean up the software, run the following command from its
directory:
```
sudo bash uninstall
```
Note that this uninstall script will delete the /opt/cuACS
directory we are storing local files in. If you wish to retain this
directory, you may want to run:
```
make clean
```
Instead. This will clean up the software directory without
affecting /opt/cuACS. You will likely be prompted to input your
administrator password in order to run the uninstall script with
sudo.
## A note for developers
When you open the project in QT Creator, it has its own build
directory in mind, and does not know to deploy the local files to
/opt/cuACS. Either run the installer script yourself, or manually
move the files over.
./sqlhandler.cpp
#include "sqlhandler.h"
const QString SqlHandler::DB_LOCATION =
"/opt/cuACS/Animal.db";
QSqlDatabase SqlHandler::db =
QSqlDatabase::addDatabase("QSQLITE", "Connection");
std::vector<Animal *> SqlHandler::fetchDatabase()
{
std::vector<Animal *> returnValue = std::vector<Animal
*>();
db.setDatabaseName(DB_LOCATION);
if (!db.open()) {
qDebug("Error occurred opening the database.");
qDebug("%s.", qPrintable(db.lastError().text()));
throw "Error opening database.";
}
QSqlQuery query(db);
//Get the properties for all the animals in the table
query.prepare("SELECT animal_ID, name, type, color, age,
weight_kg, gender, size FROM animal");
if (!query.exec()) {
qDebug("Error occurred querying.");
qDebug("%s.", qPrintable(db.lastError().text()));
db.close();
throw "Error reading database.";
}
//For each animal, assemble the object in memory from the
properties retrieved from the server
while (query.next()) {
int id = query.value(0).toInt();
std::string name = qPrintable(query.value(1).toString());
std::string type = qPrintable(query.value(2).toString());
std::string color = qPrintable(query.value(3).toString());
int age = query.value(4).toInt();
int weight = query.value(5).toInt();
std::string gender = qPrintable(query.value(6).toString());
std::string size = qPrintable(query.value(7).toString());
returnValue.push_back(new Animal(id, name, type, color,
age, weight, gender, size));
}
db.close();
return returnValue;
}
bool SqlHandler::updateItem(Animal * animal)
{
db.setDatabaseName(DB_LOCATION);
if (!db.open()) {
qDebug("Error occurred opening the database.");
qDebug("%s.", qPrintable(db.lastError().text()));
return false;
}
QSqlQuery query(db);
//Update the animal corresponding to our ID in the database
with the current property values
query.prepare("UPDATE animal SET name=:name,
type=:type, color=:color, age=:age, weight_kg=:weight,
gender=:gender, size=:size WHERE animal_ID=:id");
query.bindValue(":name", QVariant(animal-
>getName().c_str()));
query.bindValue(":color", QVariant(animal-
>getColor().c_str()));
query.bindValue(":type", QVariant(animal-
>getSpecies().c_str()));
query.bindValue(":age", QVariant(animal->getAge()));
query.bindValue(":weight", QVariant(animal->getWeight()));
query.bindValue(":gender", QVariant(animal-
>getGender().c_str()));
query.bindValue(":size", QVariant(animal-
>getSize().c_str()));
query.bindValue(":id", QVariant(animal->getId()));
if (!query.exec()) {
qDebug("Error occurred querying.");
qDebug("%s.", qPrintable(db.lastError().text()));
db.close();
return false;
}
db.close();
return true;
}
bool SqlHandler::addNew(Animal * animal)
{
if (animal->getId() >= 0) {
return false;
}
db.setDatabaseName(DB_LOCATION);
if (!db.open()) {
qDebug("Error occurred opening the database.");
qDebug("%s.", qPrintable(db.lastError().text()));
return false;
}
//Add the animal to the database
QSqlQuery query(db);
query.prepare("INSERT INTO animal (name, color, type,
age, weight_kg, gender, size) VALUES (:name, :color, :type,
:age, :weight, :gender, :size)");
query.bindValue(":name", QVariant(animal-
>getName().c_str()));
query.bindValue(":color", QVariant(animal-
>getColor().c_str()));
query.bindValue(":type", QVariant(animal-
>getSpecies().c_str()));
query.bindValue(":age", QVariant(animal->getAge()));
query.bindValue(":weight", QVariant(animal->getWeight()));
query.bindValue(":gender", QVariant(animal-
>getGender().c_str()));
query.bindValue(":size", QVariant(animal-
>getSize().c_str()));
if (!query.exec()) {
qDebug("Error occurred inserting.");
qDebug("%s.", qPrintable(db.lastError().text()));
db.close();
return false;
}
//Retrieve the auto-generated id from the database for the
animal we just put in
QSqlQuery idQuery(db);
idQuery.prepare("SELECT animal_ID FROM animal WHERE
name=:name AND type=:type AND color=:color AND age=:age
AND weight_kg=:weight AND gender=:gender AND
size=:size");
idQuery.bindValue(":name", QVariant(animal-
>getName().c_str()));
idQuery.bindValue(":color", QVariant(animal-
>getColor().c_str()));
idQuery.bindValue(":type", QVariant(animal-
>getSpecies().c_str()));
idQuery.bindValue(":age", QVariant(animal->getAge()));
idQuery.bindValue(":weight", QVariant(animal-
>getWeight()));
idQuery.bindValue(":gender", QVariant(animal-
>getGender().c_str()));
idQuery.bindValue(":size", QVariant(animal-
>getSize().c_str()));
if (!idQuery.exec()) {
qDebug("Error occurred querying.");
qDebug("%s.", qPrintable(db.lastError().text()));
db.close();
return false;
}
idQuery.next();
//Set the animal object's ID to match the database ID.
animal->setId(idQuery.value(0).toInt());
db.close();
return true;
}
SqlHandler::SqlHandler()
{
}
cuACS Requirements Analysis Summary
cuACS Requirements Analysis Summary

More Related Content

Similar to cuACS Requirements Analysis Summary

Pandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange PluginPandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange PluginPandora FMS
 
osd ncc education assingment l4dc
osd ncc education assingment l4dcosd ncc education assingment l4dc
osd ncc education assingment l4dcDavid Parker
 
Attendance Management System
Attendance Management SystemAttendance Management System
Attendance Management SystemArhind Gautam
 
SOFTWARE REQUIREMENTS SPECIFICATION.pdf
SOFTWARE REQUIREMENTS SPECIFICATION.pdfSOFTWARE REQUIREMENTS SPECIFICATION.pdf
SOFTWARE REQUIREMENTS SPECIFICATION.pdfFarDeen11
 
Distributed Exam system
Distributed Exam systemDistributed Exam system
Distributed Exam systemGCWUF
 
Software Requirements ElicitationRequirements specify a set of f.docx
Software Requirements ElicitationRequirements specify a set of f.docxSoftware Requirements ElicitationRequirements specify a set of f.docx
Software Requirements ElicitationRequirements specify a set of f.docxwhitneyleman54422
 
Final project se
Final project seFinal project se
Final project sehira akram
 
Refining The System Definition
Refining The System DefinitionRefining The System Definition
Refining The System DefinitionSandeep Ganji
 
Online-Voting-System.doc
Online-Voting-System.docOnline-Voting-System.doc
Online-Voting-System.docShangaviS2
 

Similar to cuACS Requirements Analysis Summary (20)

Pandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange PluginPandora FMS: End to End Exchange Plugin
Pandora FMS: End to End Exchange Plugin
 
osd ncc education assingment l4dc
osd ncc education assingment l4dcosd ncc education assingment l4dc
osd ncc education assingment l4dc
 
Attendance Management System
Attendance Management SystemAttendance Management System
Attendance Management System
 
Lec-9.ppt
Lec-9.pptLec-9.ppt
Lec-9.ppt
 
Chapter 5 - Tools
Chapter 5 - ToolsChapter 5 - Tools
Chapter 5 - Tools
 
Online computer shop 111 35-181
Online computer shop 111 35-181Online computer shop 111 35-181
Online computer shop 111 35-181
 
SOFTWARE REQUIREMENTS SPECIFICATION.pdf
SOFTWARE REQUIREMENTS SPECIFICATION.pdfSOFTWARE REQUIREMENTS SPECIFICATION.pdf
SOFTWARE REQUIREMENTS SPECIFICATION.pdf
 
SRS CPP LAB.docx
SRS CPP LAB.docxSRS CPP LAB.docx
SRS CPP LAB.docx
 
Distributed Exam system
Distributed Exam systemDistributed Exam system
Distributed Exam system
 
Software Requirements ElicitationRequirements specify a set of f.docx
Software Requirements ElicitationRequirements specify a set of f.docxSoftware Requirements ElicitationRequirements specify a set of f.docx
Software Requirements ElicitationRequirements specify a set of f.docx
 
Final project se
Final project seFinal project se
Final project se
 
E-LEARNING
E-LEARNINGE-LEARNING
E-LEARNING
 
Ems
EmsEms
Ems
 
Srs(at)
Srs(at)Srs(at)
Srs(at)
 
Acceptance test plan_4-24-07
Acceptance test plan_4-24-07Acceptance test plan_4-24-07
Acceptance test plan_4-24-07
 
Refining The System Definition
Refining The System DefinitionRefining The System Definition
Refining The System Definition
 
Use Case
Use CaseUse Case
Use Case
 
Online-Voting-System.doc
Online-Voting-System.docOnline-Voting-System.doc
Online-Voting-System.doc
 
11 req specs
11 req specs11 req specs
11 req specs
 
Srs template
Srs templateSrs template
Srs template
 

More from dorishigh

Cyber War versus Cyber Realities Cyber War v.docx
Cyber War versus Cyber Realities Cyber War v.docxCyber War versus Cyber Realities Cyber War v.docx
Cyber War versus Cyber Realities Cyber War v.docxdorishigh
 
Cyber terrorism, by definition, is the politically motivated use.docx
Cyber terrorism, by definition, is the politically motivated use.docxCyber terrorism, by definition, is the politically motivated use.docx
Cyber terrorism, by definition, is the politically motivated use.docxdorishigh
 
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docx
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docxCyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docx
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docxdorishigh
 
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docx
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docxCyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docx
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docxdorishigh
 
Cyber Security and the Internet of ThingsVulnerabilities, T.docx
Cyber Security and the Internet of ThingsVulnerabilities, T.docxCyber Security and the Internet of ThingsVulnerabilities, T.docx
Cyber Security and the Internet of ThingsVulnerabilities, T.docxdorishigh
 
Cyber Security Gone too farCarlos Diego LimaExce.docx
Cyber Security Gone too farCarlos Diego LimaExce.docxCyber Security Gone too farCarlos Diego LimaExce.docx
Cyber Security Gone too farCarlos Diego LimaExce.docxdorishigh
 
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docx
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docxCW 1R Checklist and Feedback Sheet Student Copy Go through this.docx
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docxdorishigh
 
CW 1 Car Industry and AIby Victoria StephensonSubmission.docx
CW 1 Car Industry and AIby Victoria StephensonSubmission.docxCW 1 Car Industry and AIby Victoria StephensonSubmission.docx
CW 1 Car Industry and AIby Victoria StephensonSubmission.docxdorishigh
 
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docx
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docxCWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docx
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docxdorishigh
 
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docx
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docxCw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docx
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docxdorishigh
 
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docx
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docxCyber AttacksProtecting National Infrastructure, 1st ed.Ch.docx
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docxdorishigh
 
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docx
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docxCVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docx
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docxdorishigh
 
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docx
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docxCYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docx
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docxdorishigh
 
CUSTOMERSERVICE-TRAINIGPROGRAM 2 TA.docx
CUSTOMERSERVICE-TRAINIGPROGRAM 2  TA.docxCUSTOMERSERVICE-TRAINIGPROGRAM 2  TA.docx
CUSTOMERSERVICE-TRAINIGPROGRAM 2 TA.docxdorishigh
 
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docx
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docxCustomer Service Test (Chapter 6 - 10)Name Multiple Choice.docx
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docxdorishigh
 
Customer Value Funnel Questions1. Identify the relevant .docx
Customer Value Funnel Questions1. Identify the relevant .docxCustomer Value Funnel Questions1. Identify the relevant .docx
Customer Value Funnel Questions1. Identify the relevant .docxdorishigh
 
Customer service is something that we have all heard of and have som.docx
Customer service is something that we have all heard of and have som.docxCustomer service is something that we have all heard of and have som.docx
Customer service is something that we have all heard of and have som.docxdorishigh
 
Customer requests areProposed Cloud Architecture (5 pages n.docx
Customer requests areProposed Cloud Architecture (5 pages n.docxCustomer requests areProposed Cloud Architecture (5 pages n.docx
Customer requests areProposed Cloud Architecture (5 pages n.docxdorishigh
 
Customer Relationship Management Presented ByShan Gu Cris.docx
Customer Relationship Management Presented ByShan Gu Cris.docxCustomer Relationship Management Presented ByShan Gu Cris.docx
Customer Relationship Management Presented ByShan Gu Cris.docxdorishigh
 
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docx
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docxCustom Vans Inc. Custom Vans Inc. specializes in converting st.docx
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docxdorishigh
 

More from dorishigh (20)

Cyber War versus Cyber Realities Cyber War v.docx
Cyber War versus Cyber Realities Cyber War v.docxCyber War versus Cyber Realities Cyber War v.docx
Cyber War versus Cyber Realities Cyber War v.docx
 
Cyber terrorism, by definition, is the politically motivated use.docx
Cyber terrorism, by definition, is the politically motivated use.docxCyber terrorism, by definition, is the politically motivated use.docx
Cyber terrorism, by definition, is the politically motivated use.docx
 
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docx
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docxCyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docx
Cyber Security ThreatsYassir NourDr. Fonda IngramETCS-690 .docx
 
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docx
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docxCyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docx
Cyber Security in Industry 4.0Cyber Security in Industry 4.0 (.docx
 
Cyber Security and the Internet of ThingsVulnerabilities, T.docx
Cyber Security and the Internet of ThingsVulnerabilities, T.docxCyber Security and the Internet of ThingsVulnerabilities, T.docx
Cyber Security and the Internet of ThingsVulnerabilities, T.docx
 
Cyber Security Gone too farCarlos Diego LimaExce.docx
Cyber Security Gone too farCarlos Diego LimaExce.docxCyber Security Gone too farCarlos Diego LimaExce.docx
Cyber Security Gone too farCarlos Diego LimaExce.docx
 
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docx
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docxCW 1R Checklist and Feedback Sheet Student Copy Go through this.docx
CW 1R Checklist and Feedback Sheet Student Copy Go through this.docx
 
CW 1 Car Industry and AIby Victoria StephensonSubmission.docx
CW 1 Car Industry and AIby Victoria StephensonSubmission.docxCW 1 Car Industry and AIby Victoria StephensonSubmission.docx
CW 1 Car Industry and AIby Victoria StephensonSubmission.docx
 
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docx
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docxCWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docx
CWTS CWFT Module 7 Chapter 2 Eco-maps 1 ECO-MAPS .docx
 
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docx
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docxCw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docx
Cw2 Marking Rubric Managerial Finance0Fail2(1-29) Fail.docx
 
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docx
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docxCyber AttacksProtecting National Infrastructure, 1st ed.Ch.docx
Cyber AttacksProtecting National Infrastructure, 1st ed.Ch.docx
 
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docx
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docxCVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docx
CVPSales price per unit$75.00Variable Cost per unit$67.00Fixed C.docx
 
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docx
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docxCYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docx
CYB207 v2Wk 4 – Assignment TemplateCYB205 v2Page 2 of 2.docx
 
CUSTOMERSERVICE-TRAINIGPROGRAM 2 TA.docx
CUSTOMERSERVICE-TRAINIGPROGRAM 2  TA.docxCUSTOMERSERVICE-TRAINIGPROGRAM 2  TA.docx
CUSTOMERSERVICE-TRAINIGPROGRAM 2 TA.docx
 
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docx
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docxCustomer Service Test (Chapter 6 - 10)Name Multiple Choice.docx
Customer Service Test (Chapter 6 - 10)Name Multiple Choice.docx
 
Customer Value Funnel Questions1. Identify the relevant .docx
Customer Value Funnel Questions1. Identify the relevant .docxCustomer Value Funnel Questions1. Identify the relevant .docx
Customer Value Funnel Questions1. Identify the relevant .docx
 
Customer service is something that we have all heard of and have som.docx
Customer service is something that we have all heard of and have som.docxCustomer service is something that we have all heard of and have som.docx
Customer service is something that we have all heard of and have som.docx
 
Customer requests areProposed Cloud Architecture (5 pages n.docx
Customer requests areProposed Cloud Architecture (5 pages n.docxCustomer requests areProposed Cloud Architecture (5 pages n.docx
Customer requests areProposed Cloud Architecture (5 pages n.docx
 
Customer Relationship Management Presented ByShan Gu Cris.docx
Customer Relationship Management Presented ByShan Gu Cris.docxCustomer Relationship Management Presented ByShan Gu Cris.docx
Customer Relationship Management Presented ByShan Gu Cris.docx
 
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docx
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docxCustom Vans Inc. Custom Vans Inc. specializes in converting st.docx
Custom Vans Inc. Custom Vans Inc. specializes in converting st.docx
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

cuACS Requirements Analysis Summary

  • 1. cuACS Requirements Analysis Document Nicholas Aubé 101032093 Ibiduneyitayo, 101018199 Peter MacDonald, 100683150 Submitted to: Dr. Christine Laurendeau COMP 3004 Object-Oriented Software Engineering School of Computer Science Carleton University
  • 2. 1 Table of Contents Introduction + Overview of Document…………………………………………………………… ……………….1 Functional Requirements…………..…………………………………………… ………..……………………………..2 Non-functional Requirements………………………………………………………… ……………………………2-4 Use Case Model………………………………………………………………… ………………………….……………4-15 Object Model………………………………………………………………… …………………………………………...…16 Introduction
  • 3. The cuACS program is designed to find the best possible matches between a variety of different animals and clients that are looking for a new pet. The Carleton University Animal Case System will revolutionize the way that we adopt animals. The main advantage of the cuACS system is the dynamic algorithm that matches shelter animals and human clients based on compatibility factors such as habitat, size, and temperament. The algorithm is optimized to create the largest number of sufficient matches, not just one or two perfect ones. The cuACS program will allow clients to look at animal profiles and edit their own detailed profiles. There will also be functionality to manage client profiles and animal preferences. There are even multiple types of users that can access the system, staff and clients. Both types of users have different permissions, which will be managed by the system. This report will cover many different aspects of the cuACS system, including an
  • 4. overview of the program, functional and non-functional requirements, the user case model and the object model. 2 Functional requirements Traceability: functional requirements are preceded by the letter F when referred to in other sections of the requirements analysis. E.g. F-1.1 refers to the staff interaction 1.1 functional requirement. 1. Staff interactions 1.1. Staff should be able to add new animals and clients 1.2. Staff should be able to view client and animal information 1.3. Staff should be able to edit animal and client profiles 1.4. Staff should be able to start the Matching algorithm process 1.5. Staff should be able to view a summary of matches made by the Matching algorithm 1.6. Staff should be able to view the details of a specific match made by the algorithm
  • 5. 2. Client interactions 2.1. Clients can view and edit their profile 2.2. Clients can view animal profiles 3. Algorithm 3.1. There should be an algorithm that can create optimal matches between clients and animals 3.2. The algorithm should look at client preferences and match them with animal traits 3.3. The algorithm should attempt to create the largest number of acceptable matches possible rather than a small number of extremely compatible matches. 3.4. The algorithm should provide output in a form that can be easily turned into a report for user reading. Non-Functional Requirements Traceability: non-functional requirements are preceded by the letters NF when referred to in other sections of the requirements analysis. E.g. NF-1.1 refers to the open source
  • 6. licensing non-functional requirement. 1. Legal 1.1. Our software must be distributed under an open source licence 1.2. Our software’s use of the QT framework must conform to the terms of its Open-Source GPL 3.0 licence. 1.3. Our software must be licensed for non-profit use only 2. Usability 2.1. All error messages should be descriptive and, where applicable, suggest solutions 3 2.2. The GUI should provide hotkey shortcuts for common tasks on relevant platforms 2.3. The database should be automatically updated when users have finished editing a profile, without requiring them specific user input.
  • 7. 3. Reliability 3.1. If the system fails while a profile is being updated they should be prompted to save their progress 3.2. The system should be able to perform the functional requirements without crashing, hanging, or otherwise failing. 3.3. The system should consistently be able to run without crashing after release 4. Performance 4.1 The matching algorithm should provide results in a reasonable time frame (< 60 seconds). 4.2 The program should minimize both system resources and system time by ensuring that unnecessary calls to the database are avoided 4.3 When running the matching algorithm, the thread that is handling UI processes should not be blocked while waiting for the results. 5. Supportability 5.1. The back-end and the GUI should be sufficiently decoupled that porting the
  • 8. system to a different GUI framework would be easy 5.2. Adding, removing, or modifying animal and client traits should be easy 5.3. Modifying one part of the GUI should not require remaking other portions to preserve functionality 6. Implementation 6.1. The system must be written in C++ 6.2. The system needs to have a GUI 6.3. Persistent storage must be provided through an SQL database 7. Interface 7.1. The interface should be clean and professional 7.2. The interface needs to have a sign in as either a staff member or a client 7.3. The interface should be designed and programmed using the QT framework 8. Operations 8.1. The client should not be able to access the information of other clients 8.2. The client should not be able to modify the information of
  • 9. animals 8.3. Only staff members can create client profiles and 9. Packaging 9.1. The system should build in a single command and run with a single command 9.2. The system must be accessible as an executable for download 4 9.3. The codebase should be packaged in a way that it is easy to navigate and intuitive for all programmers to be able to easily find the intended piece of code Use Case Model Diagrams
  • 11. 10 11 12 Reminder: UC-3.1 refers to the algorithm use case where it creates matches. Descriptions Use Case Identifier UC-1.1/UC-1.2 Name StaffAddClient/StaffAddAnimal Participating actors StaffMember Flow of events 1. A staff member starts the creation process 2. The program creates the form to initialize the new item’s properties 3. The staff member fills out the form and submits it 4. The program will add the new client/animal to the appropriate table after verifying that all the fields are entered correctly
  • 12. Entry conditions The Staff member elects to begin the creation process Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the staff portion of the software. Traceability F-1.1 13 Use Case Identifier UC-1.3/UC1.4 Name StaffViewClient/StaffViewAnimal Participating actors StaffMember Flow of events 1. A staff member selects the client or animal profile that they would like to view 2. The staff member clicks on the view details button 3. The program opens the details page for the client or animal Entry conditions The Staff member elects to open the details page Exit conditions The program returns back to the main menu Quality requirements The user must be in the staff portion of the software. Traceability F-1.2 Use Case Identifier UC-1.5/UC1.6 Name StaffEditClient/StaffEditAnimal
  • 13. Participating actors StaffMember Flow of events 1. A staff member starts the edit process 2. The program creates the form to edit the item’s properties 3. The staff member fills out the form and submits it 4. The program will update the client/animal to the appropriate table after verifying that all the fields are entered correctly Entry conditions The Staff member elects to open the edit page Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the staff portion of the software. Traceability F-1.3 Use Case Identifier UC-1.7 Name StaffStartAlgorithm Participating actors StaffMember Flow of events 1. A staff member starts the algorithm 2. The program creates the appropriate matches and saves them Entry conditions The Staff member elects to start the algorithm Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the staff portion of the software. Traceability F-1.4 Use Case Identifier UC-1.8 Name StaffViewMatchSummary Participating actors StaffMember Flow of events 1. A staff member starts UC-1.7 2. The program creates the appropriate matches and saves them
  • 14. 3. The staff member clicks the summary button of the algorithm 4. The program reprints the general summary of the matches Entry conditions The Staff member elects to open the summary of matches Exit conditions The system will return to the menu Quality requirements The user must be in the staff portion of the software. Traceability F-1.5 14 Use Case Identifier UC-1.9 Name StaffViewMatchDetails Participating actors StaffMember Flow of events 1. A staff member starts UC-1.7 2. The program creates the appropriate matches and saves them 3. The staff member clicks the details button on a certain match 4. The program prints the summary of that specific match Entry conditions The Staff member elects to start the algorithm Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the staff portion of the software. Traceability F-1.6 Use Case Identifier UC-2.1/UC-2.2 Name ClientViewSelf/ClientEditSelf Participating actors ClientMember
  • 15. Flow of events 1. A client clicks on their profile 2. For UC-2.2, the client can press the edit button on their profile a) The program creates a form for the user to make changes and submit b) The user submits the updated information and the program checks to make sure it is correct c) The program updates the client’s profile and returns back to their profile page 3. The program displays the client’s profile Entry conditions The Staff member elects to view their profile Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the client portion of the software. Traceability F-2.1 Use Case Identifier UC-2.3 Name ClentViewAnimal Participating actors ClientMember Flow of events 1. Client clicks on the animal details button 2. Program fetches and displays the list of animals and their details Entry conditions The Staff member elects to open the animals page Exit conditions The program returns back to the main menu Quality requirements The user must be in the client portion of the software.
  • 16. Traceability F-2.2 15 Use Case Identifier UC-3.1 Name StaffStartMatches Participating actors StaffMember Flow of events 1. The program is called to make matches 2. The algorithm fetches animal information and client preferences and creates matches according to all F-3.X functional requirements 3. The program saves the displays the matches Entry conditions The Staff member elects begin the matching algorithm Exit conditions The system will return a message saying that the action is complete Quality requirements The user must be in the staff portion of the software. Traceability F-3.1, F-3.2, F-3.3, F-3.4
  • 17. Object Model Data Dictionary Name / ID Number Attributes / Associations Definition Use Cases User O-01 • Username • password A user of the cuACS system. All use Cases Staff User O-02 • Has access to the client database • Has access to the animal database • Has access to the matching system • Is a User
  • 18. A user of the cuACS system with staff/writing privileges. UC-1.1 UC-1.2 UC-1.3 UC-1.4 UC-1.5 UC-1.6 UC-1.7 UC-1.8 UC-1.9 UC-3.1 Client User O-03 • Has a client profile in the Client database • Has read-only access to the animal database • Is a User A user of the cuACS system with client privileges. UC-2.1 UC-2.2 UC-2.3 16
  • 19. Client Profile O-04 • Stored in the client database • Can be edited by any staff user • Can be edited by one client user • Used by the Matching System to create Matches • Name • Age • Gender • Size preference • Species preference • Allergies • Living space • Activity level preference • Family size A profile in the cuACS system that describes a client and their preferences. UC-1.1 UC-2.1
  • 20. UC-2.2 UC-2.3 UC-3.1 Animal Profile O-05 • Stored in the animal database • Can be edited by any staff user • Can be viewed by any Client user • Used by the Matching System to create Matches • Name • Species • Gender • Weight • Size • Color • Age • Ease of training • Playfulness • Friendliness with strangers • Friendliness with children
  • 21. • Aggressiveness • Activity Level • Affection Level • Hypoallergenic (yes/no) • Nocturnal (yes/no) • Shedding level • Living area needed • Ideal habitat A profile in the cuACS system that describes an animal kept at the shelter and up for adoption. UC-1.1 UC-1.3 UC-1.4 UC-1.5 UC-1.6 UC-1.7 UC-1.8 UC-1.9 UC-3.1 17 • Indoors or outdoors pet? • Preferred climate • Responsiveness to toys • Diet
  • 22. Client Database O-06 • Contains client profiles • Can be read by staff users • Can be edited by staff users • Can be read by the Matching System The database system storing the client profiles for the cuACS system. UC-1.1 UC-1.3 UC-1.5 UC-1.7 UC-3.1 Animal Database O-07 • Contains animal profiles • Can be read by all users • Can be edited by staff
  • 23. users • Can be read by the Matching System The database system storing the animal profiles for the cuACS system. UC-1.2 UC-1.4 UC-1.6 UC-1.7 UC-2.3 UC-3.1 Match O-08 • Contains one animal and one client • Created by the Matching system • Can be viewed by staff users A match between a client and a compatible animal, as judged by the Matching system UC-1.8 UC-1.9 UC-3.1
  • 24. Matching System O-09 • Can read client database • Can read animal database • Can be activated and viewed by staff users • Creates matches • Stores matches This system reads both the client and animal databases and creates matches between compatible clients and animals. UC-1.7 UC-1.8 UC-3.1 Association Diagrams 18
  • 25. Fig 1: 19 Fig 2: INSCRIBED LANDSCAPES Travel Writing from Imperial China Translated with Annotations and an Introduction by RICHARD E. STRASSBERG UNIVERSITY OF CALIFORNIA PRESS BERKELEY LOS ANGELES LONDON 16 Fan Chung-yen (989-1052) j~ 1~ ~~ Fan Chung-yen was born in Su-chou in what is today Chiang-su.
  • 26. His father died when he was still young, and he was educated in Buddhist temple schools with the support of patrons. Becoming a Presented Scholar in 1015, he enjoyed a distinguished career, although he suffered demotion three times during his early years in office. He was nevertheless admired as an idealistic Confucian and achieved notable success in military and diplomatic affairs. In 1041, when he was auxiliary academician of the Dragon Diagram Hall, he was sent as assistant military commissioner for the Shaan-hsi Circuit, where he fortified a critical area against the Hsi-Hsia Kingdom and arranged a durable peace between the two countries. In 1043, he proposed a reform program-later regarded as the "Minor Reform" of the Northern Sung, since it antedated the more pervasive reforms of Ou- yang Hsiu and Wang An-shih (1021-1086). It failed in 1045 owing to political opposition. Fan was then assigned to local posts at his request, where he continued to serve with distinction as a prefect. His literary theory embraced the ideals of Ancient Style prose but also included interest in the conventions of parallel prose. The Pavilion ofYueh-yang was commissioned by a friend, T'eng Tzu-ching (991- 1047), who, like Fan, was demoted and exiled to the post of prefect. Fan wrote the piece from a distance, relying both on his memory
  • 27. of the place and on an illustration. It became one of the most widely known works of travel literature, combining a documentary function with a lyrical description of the scenery that reflects the ambivalent moods of the writer. His statement "First feel concern for the concerns of the world. Defer pleasure until the world can take pleasure" became an enduring motto for Confucian officials. · 157 158 FAN CHUNG-YEN The Pavilion ofYiieh-yang faces Grotto Lake and was first built above the West Gate of the city wall ofYiieh-yang in present- day Hu- nan during the K'ai-yiian era (713-741) of the T'ang dynasty. It was renovated a number of times through the centuries and was completely rebuilt in 1867. Presently, its three stories stand about sixty- five feet high. Although celebrated as early as the T'ang in a poem by Tu Fu (712-770), the pavilion became a literary shrine largely as a result of Fan Chung-yen's account. Later, an engraving of this piece written by the Ch'ing calligrapher Chang Chao (169I-1745) was placed inside the main hall.
  • 28. The Pavilion ofYiieh-yang *~t!~C. (1046) In the spring of the fourth year of the Ch'ing-li era [1044], T'eng Tzu- ching was demoted to the post of prefect of Pa-ling. 1 Two years later, his administration was well ordered and the people lived in harmony; numerous affairs that had languished were revived with success. Then he had the Pavilion of Yiieh-yang restored, expanding its original de- sign. Poems and prose by worthies of the T'ang as well as by men of the present dynasty were inscribed upstairs. I was asked to write a piece in commemoration. I have observed the magnificent scenery of Pa-ling at this lake named "Grotto," which bites the distant mountains and swallows up the Long River, surging restlessly as it extends beyond the horizon. Be- tween the radiant mornings and the shadowy twilight, its atmosphere undergoes myriad transformations. This is the grand view from the Pavilion of Yiieh-yang, which ancient writers have described in detail. Because the water routes lead north to Shaman's Gorge and stretch south all the way to the Hsiao and Hsiang rivers, exiled officials and tragic poets have always gathered here. Did they not have various feel- ings upon viewing this scene?
  • 29. When it rains constantly in heavy showers and the sun does not shine through for months on end, cold winds howl, and muddy waves strike at the sky. The sun and stars hide their radiance; the hills and mountains conceal their forms. Merchants and travelers cannot set sail, for the masts would break and the oars snap. At twilight, all turns to darkness: tigers roar and gibbons cry. Ascending to the pavilion now, FAN CHUNG-YEN I59 one feels remote from the capital and longs for home, worried about slander and fearful of ridicule. A bleak vista fills one's eyes; regrets in- tensify and turn to melancholy. When it turns to balmy spring and the entire scene brightens, the waves are no longer aroused. The sky above and its reflection below form a single, vast expanse of blue-green. Seagulls soar about and gather to rest; colorful fish swim and submerge. Angelica by the banks and orchids on the islets diffuse their fragrances as they flourish. And sometimes, when the blanketing mist vanishes, the luminous moon shines for a thousand li. Floating light beams shimmer like
  • 30. gold; the moon's quiet reflection forms a submerged jade disc. Fishermen's songs respond to one another. How could one ever tire of such joy? Ascend- ing to the pavilion now, one's heart opens and one's spirit is delighted. Favor and disgrace are both forgotten as one faces the breeze with a cup of wine in boundless satisfaction. Ah! I have often sought to attain the mind of those ancient paragons of humaneness, for some of them did not experience these two kinds of feelings. Why was this? They took no delight in external things, nor felt sorry for themselves. When they occupied a high position at court, they felt concern for the people. When banished to distant rivers and lakes, they felt concern for their sovereign. When serving at court, they felt concern, when forced to withdraw they felt concern. Then when did they enjoy happiness? Would these ancients not have said, "First feel concern for the concerns of the world. Defer pleasure until the world can take pleasure." Alas! If there were not such people, then whom could I follow? ON THE FIFTEENTH DAY OF THE NINTH LUNAR MONTH IN THE SIXTH YEAR [OCTOBER I7, I046J2
  • 31. Fig. 23. Chin Nung (1687-1773), "Tilt Pavilion oftht Old Dnmkard" by 0••-yaug Hsiu. Leaf f of Album of Ltmdscapts Illustrating Poems and Essays By Famous Writers (1736), Museum Rietberg, Zurich, Gift of Charles A. Drenowatz. Ou-yang Hsiu is depicted here sitting with a companion by the pavilion with his travel account fully inscribed as a colophon. 17 Ou-yang Hsiu (1007-1072) ~k~1~ Ou-yang Hsiu was one of the dominant figures ofNorthern Sung literature and politics, a leader of a circle ofliterary progressives who consolidated the ideals of the Ancient Style. Later canonized as one of the Eight Masters ofT'ang and Sung Prose, he was a prolific writer in a variety of prose and poetic genres. Born in Yung-feng, Chi Prefecture (modern Chi-shui, Chiang-hsi), Ou-yang entered the Imperial University after twice failing the prefectural examinations and, in 1030, distinguished himself by placing fourteenth in the palace
  • 32. examinations. In 1036, he was exiled and demoted for supporting Fan Chung-yen's criticisms; he was recalled in 1040 along with Fan and rose to become a drafting official because ofhis fame as a writer. Fan and his faction again fell from power in 1045. The following year, Ou- yang's reputation was damaged by a scandal in which he was falsely charged with incest and imprisoned; his known fondness for singers and writing romantic poetry may have made him particularly vulnerable to such charges. After his acquittal, he was once again exiled and made prefect of Ch'u Prefecture (modern Ch'u District, An- hui), where he wrote The Pavilion of the Old Drunkard, one of his most enduring works. Ou-yang Hsiu subsequently served as prefect of Yang-chou, where he revived his romantic reputation, as well as prefect ofYing Prefecture (modern Fu-yang, An-hui), a scenic area where he later retired. He returned to the capital in 1054 and became increasingly influential in the central government, rising to the powerful position of assistant chief minister. During the following period of thirteen years he served as co-editor of The New History of the T'ang Dynasty (Hsin T'ang shu, 1060) and single-handedly wrote The New History of the Five Dynasties (Hsin Wu-tai shih, posthumously 161
  • 33. 162 OU-YANG HSIU published in 1072) as models of the Ancient Style; both works were praised by literary stylists but later criticized by historians. He further consolidated the position of the Ancient Style when, as chief examiner in 1057, he required it in examination essays and failed those who wrote in other styles. It was through this examination that he discovered Su Shih and Su Ch'e, destined to become leading literary figures of the next generation. Ou-yang Hsiu served in various high- level positions during the 106os, and his administration was noted for its stability and several progressive reforms. However, he was again falsely accused of incest, though again cleared. He repeatedly requested assignments away from the capital and finally, in 1071, was allowed to retire with the title of Junior Preceptor of the Heir Apparent. Ou-yang Hsiu left over five hundred pieces of prose in a variety of forms, all characterized by a tight sense of structure. He was also an early proponent of the miscellany (pi-chi), producing several influential collections as well as an early travel diary, Diary of My Route to Assume Office (Yii-i chih), written while journeying to a new post to which he was demoted in 1036. In The Pavilion of the Old
  • 34. Drunkard, the presence of parallelistic elements and syntactical repetitions create a sense of playfulness and humor reflecting the informality of the piece. Ou-yang was relatively unconcerned with the metaphysics of Nature or speculative philosophy; this piece reveals instead his pragmatic interest in concrete human activity and in the texture of the observable world. Its cumulative effect is to convey Ou-yang Hsiu's undiminished humanity and commitment while an official in exile. The Pavilion of the Old Drunkard (Tsui-weng-t'ing) is located on Lang-ya Mountain in the southwest of modern Ch'u District, An-hui, about two miles from the city. It was ordered built by Ou-yang Hsiu himself, who had the monk Chih-hsien supervise its construction on a scenic spot next to a spring. The elegant open building has been restored many times, and the area abounds in inscriptions dating back to the T'ang and Sung. Ou-yang's original calligraphy of the text was engraved at the site in 1048 but proved unsuitable for making rubbings. In 1091, Su Shih was asked to rewrite the text in larger characters, and this engraving was widely reproduced. The Pavilion of the Old Drunkard !W- ~ .f~C. ( 1046)
  • 35. Mountains ring the seat of Ch'u Prefecture. 1 The many peaks on the southwest are especially beautiful, with their forests and valleys. I OU-Y ANG HSIU 163 gazed into the distance at one that was luxuriant, deep, and graceful- Lang-ya Mountain. 2 I walked more than two miles up the mountain and gradually heard the gurgling sound of water, "ch'an-ch'an," until I found, splashing out from between two peaks-Fermentation Spring. The peaks circled around me as the road twisted and turned until there was a pavilion with eaves like wings, facing the spring-the Pavilion of the Old Drunkard. Who built this pavilion? A monk on the mountain -Chih-hsien. Who named this pavilion? The Prefect did, after himself. For the Prefect comes here to drink with his guests. After drinking only a bit, he quickly becomes drunk, and because he is the oldest, he calls himself "the Old Drunkard." But wine is not uppermost in the Old Drunkard's mind. What he cares about is to be amid moun- tains and streams. The joy of the landscape has been captured in his heart, and wine drinking merely expresses this.
  • 36. When the sun appears, the mist disperses through the forest; when clouds return to the mountains, the caves in the cliffs darken. These transformations from brightness to darkness-such is dawn and dusk on the mountain. When wildflowers blossom giving off subtle fra- grances, when fine trees flourish providing extensive shade, when the wind is clean and the frost is pure, when the water is low and the rocks become visible-such are the four seasons in these mountains. If one comes here in the morning and returns in the evening, one will notice the scenes differing throughout the four seasons and experience a joy that is likewise inexhaustible. Men bearing loads sing along the road, while travelers rest under the trees. Those in front call out; those behind respond. The elderly, hunched over ones leading the young by the hand as they come and go ceaselessly-these are the people of Ch'u on their outings. Along the stream they fish: the stream is deep, the fish, stout; they ferment the spring water into wine: the water is sweet, the wine, clear. Various kinds of mountain game and wild vegetables casually served- such is the Prefect's banquet. The gaiety of the feasting and drinking is unaccompanied by strings or flutes. Someone wins at tossing
  • 37. arrows into a pot; another gains victory at chess. Winecups and wine tallies crisscross back and forth. Shouting out as they jump up or sit down- such is the happiness of all the guests. And the person with the aged face and whitened hair who sits slumped among them-the Prefect, drunk. Before long, the sun sets behind the mountain; the people along with their shadows disperse. The Prefect returns, followed by his guests. As the forest covers everything in darkness, cries ring out all over-such is the joy of the birds as the visitors depart. The birds can 164 OU - YANC HSIU only enjoy the mountains and forests: they cannot understand the joy of people. The people can only enjoy this outing along with the Prefect: they cannot understand that the Prefect was enjoying their joy. He who, when drunk, was able to share their joy and, when sober, could describe it with literary flourish is-the Prefect. And who is this Prefect? Ou-yang Hsiu of Lu-ling. 3
  • 38. Fig. 24. Rubbing ofSu Shih's Inscription of Tile Pavilion o_{joyful Abuuda/l(e (detail. original ca. 1091 ) . From Su Shih, Fw,~-le-t'i11,~ chi (rpt. Taipei, 1975). OU-YANC HSIU 165 The Pavilion of]oyful Abundance t$.f"tC. (1046) This piece was also written while Ou-yang Hsiu was exiled in Ch'u Prefecture. In contrast to the casual attitude of The Pavilion of the Old Drunkard, this is a more decorous composition meant to be publicly displayed as an explanation of the moral significance of the pavilion's name. It displays a historical sense of place, as well as loyal political sentiments. Ou-yang Hsiu contrasts the past, a long phase of disorder 166 OU-YANG HSIU and suffering, with the present state of peace and prosperity in which he implicitly participates. The theme of joyful abundance enables him to offer praise to the dynasty that was punishing him for his views and to articulate the Confucian virtues that would merit his recall to
  • 39. the capital. The pavilion at the foot of Mount Abundance (Feng- shan) near Lang-ya Mountain was also ordered built by Ou-yang Hsiu in 1046 in order to celebrate the bountiful era. Standing beside a spring surrounded by a tall peak and bamboo-covered hills, it became a frequent destination for his excursions. The text was also rewritten by Su Shih and engraved at the site. Only in the summer of the second year after I took office in Ch'u Prefecture was I able to taste the spring water hereabouts and discover its sweetness. When I asked a local person about it, I found that it had come from the south of the prefectural city, no more than a hundred paces away. Above it stood Abundance Mountain, 1 lofty and strikingly erect; below it was a secluded valley, remote and shady, and hidden deep. Between them was a pure spring overflowing and spurting up- ward. I gazed up and peered down to the left and right, and was de- lighted at what I observed. So I cut through the rocks to make a path for the spring, and cleared some land for a pavilion so that I could make excursions here along with the people of Ch'u. Ch'u was a battlefield during the wars of the Five Dynasties. Formerly, Emperor T'ai-tsu of the Sung2 led the army of the Latter
  • 40. Chou to defeat the 150,000 troops of Li Ching at the foot of Pure Stream Mountain. 3 He took prisoner Generals Huang-fu Hui and Yao Feng outside the East Gate of the city of Ch'u Prefecture, finally pacify- ing Ch'u. 4 I investigated the terrain, consulted maps and records, climbed up high to observe Pure Stream Pass, and sought to find the place where Huang-fu Hui and Y ao Feng were captured. But there were no living survivors, for it has been a long time since peace was established through the empire. After the T'ang dynasty lost control, the entire land split apart. Strongmen arose and fought each other. Were not those warring king- doms beyond counting? Then, when the Sung received the Mandate of Heaven, a sage arose and unified all within the four seas. 5 The strategic bases of those contenders have been demolished and leveled. A century later, all is peaceful: nothing remains except the tall mountains and pure streams. I wanted to inquire about these events, but the survivors are OU-Y ANG HSIU I67 all gone now. Nowadays, Ch'u Prefecture is located between the Long
  • 41. and Huai rivers, yet merchants and travelers do not come here. The people are unaware of events outside and are content with farming and providing clothing and food so that they are happy in life and provided for in death. But who among them realizes that it is the achievements and virtue of Our Sovereign which has allowed them to thrive and prosper, flourishing for as long as a century? When I came here, I was delighted by the isolation of the place and the simplicity of official business. I was especially fond of the relaxed way oflife. So, ever since discovering this spring in a mountain valley, I have come here daily together with the people of Ch'u to look up- ward and gaze at the mountain and to peer down to listen to the spring. I gather hidden flowers and seek shade under the lofty trees. I have visited it in wind, frost, ice, and snow, when its pure beauty is revealed. The scenery during the four seasons is always charming. Moreover, it is fortunate that the people are joyful over the abundant harvests and are happy to travel here together with me. I have used this landscape to praise the excellence of their customs so as to remind the people that they can rest content in the joy of this year's abundant harvest, because
  • 42. they are fortunate enough to live during a time free from trouble. To proclaim the benevolence and virtue of Our Sovereign and share the joy of the people is the duty of a prefect. Thus, I have written this account and named the pavilion after this. WRITTEN BY OU-YANG HSIU, EXHORTER ON THE RIGHT, PROCLAMATION DRAFTER, AND PREFECT OF CH'U AND CHUN PREFECTURES, IN THE SIXTH MONTH OF THE YEAR PING-HSU DURING THE CH'ING-LI ERA [JULY-AUGUST I046) 6 2I Su Shih (1037-1101) Su Shih, widely known by his artistic name, Tung-p'o (Eastern Slope), became one of the dominant figures in Chinese literati culture, influencing not only prose and poetry but aesthetic theory, painting, and calligraphy as well. He was born into a gentry family oflimited means and educated primarily by his father, Su Hsiin (1009- 1066), later famous as a political essayist, and also by his mother, nee Ch'eng. He and his younger brother, Su Ch'e, were regarded as newly
  • 43. discovered talents after passing the Presented Scholar examination in 1057 under Ou-yang Hsiu. In 1061, Su Shih passed the special examination held to recruit new officials and began his career as a case reviewer at the Court of Judicial Review. During these early years, he wrote numerous memorials identifying critical national problems in areas of finance and military defense. Although interested in reform, he opposed Wang An- shih's New Policies, objecting to the dislocation caused by their rapid implementation and Wang's use oflegalist methods. In 1079, Su was arrested in a "literary inquisition" for allegedly defaming the court in one of his poems. After several months of investigation, he was released, demoted to the nominal post of assistant military training commissioner, and exiled to Huang Prefecture in what is today Hu-pei. There, he wrote some of his best-known travel pieces while continuing to address current issues. Given a slight promotion to Ju Prefecture in 1084, he passed through Nanking on his way and met Wang An- shih, with whom he continued to maintain cordial literary relations despite political differences. Su Shih returned to the capital after the reversal ofWang's policies
  • 44. ~~ under the Empress Dowager Hsiian-jen, regent for the young Emperor 183 184 S U SHIH Fig . .z8. Wu Yiian-chih (active late 12th cent. ), Red C/!ff(detail). National Palace Museum, Taipei. Che-tsung (r. I08s-noo), and served as a Han-lin Academician when the conservative party of Szu-ma Kuang gained power. He angered them, however, when he protested the indiscriminate dismantling of Wang's New Policies, with none of their beneficial aspects preserved, and was sent to administer Hang-chou in 1089. A series of other local posts followed in which he was able to institute progressive changes despite the reigning conservative atmosphere. In 1094 when the Che- tsung Emperor assumed personal rule, another faction supplanted those favored under the Empress Dowager, and Su Shih was again exiled, this time to remote Hai-nan Island in the south, where living conditions were particularly severe. H ere, coo, he wrote travel pieces, which continued to express his acceptance of the vicissitudes of
  • 45. life and SU SHIH 185 a vitalistic engagement with his surroundings. Pardoned in 1100 upon the accession of the Emperor Hui-tsung (r. II00-1125), he died the following year while on his way north. Though an activist Confucian official, Su Shih was eclectic in his intellectual interests. He was deeply influenced by Ch'an Buddhist concepts of enlightenment, the mind, and human nature, and searched for transcendence through engagement with social reality and the natural environment. He was also enthralled by the mysterious pageant of universal transformation. Such themes as the equivalence of objective and subjective viewpoints, the Tao as a ceaseless alternation between change and constancy, the affirmation ofhappiness in this life, equanimity toward fate, and unflagging curiosity about the natural world pervade his prolific writings. Su's shih poems alone number almost 2,8oo, of which those containing perceptions of Nature and his philosophical views have been the most widely read. His tz'u poems, numbering about 3 50, expanded the range of content in this
  • 46. genre and are considered innovative examples of an attitude of "heroic abandon" (hao1ang). One of the Eight Masters ofT'ang and Sung Prose, Su was further canonized by the literary tradition as the personification of the Northern Sung zeitgeist, an expansive, optimistic personality who later was celebrated in drama, painting, and the decorative arts. As a travel writer Su employed a variety of forms such as letters, ju rhapsodies, travel records, random notes, and prefaces. His two pieces on Red Cliff were written during his exile in Huang Prefecture. The first is perhaps the best-known work of Chinese travel writing. In it, Su Shih achieved an optimistic solution to a lyric vision imperiled by an awareness of tragic history. His mood shifted in the second piece to a sober recognition of Nature's awesome power and the limits ofhuman ambition. Yet even here he concluded with an affirmation of the possibility of transcendence. Together, these pieces became monuments of Chinese literature and art, establishing the place as a literary shrine. Red Cliff I "ff.r~5! ~ (1082) In the fall of the year jen-hsii in the seventh month on the day after the moon had reached its height [August 12, 1082], I traveled in a
  • 47. boat with some guests to the foot of Red Cliff. 1 A light wind wafted by, and not a ripple was stirred. I poured wine for my guests as we chanted the poem about the bright moon and sang the song about the graceful 186 SU SHIH maiden. 2 Before long, the moon appeared over East Mountain and lingered by the constellations Dipper and Ox. 3 White dew extended over the Long River; the water's gleam mingled with the sky. We let this reed of a boat follow its course as it traversed an expanse of myriad ch'ing. I felt boundless, as if gliding through the void not know- ing where I might land; I felt like I was soaring about, having left the world behind to stand alone as I sprouted wings to become a Transcen- dent. Then we drank more wine and reached the height of joy. I beat out a rhythm against the side of the boat and sang: Cassia-wood oars, Magnolia-wood rudder, Stroke the moon's pure reflection As we glide upstream on its shimmering light.
  • 48. Ever distant, the object of my longings. I gaze at the beautiful one In a faraway corner ofHeaven.4 One of the guests could play the flute and accompanied my song. 5 Yet his sounds-"wu-wu"-were plaintive, yearning, weeping, accus- ing. The lingering notes meandered through the air, drawn out like silken threads. They would have aroused a submerged chiao- dragon to whirl around in the cavernous depths, and caused a widow to weep in her lonely boat. I was saddened. Straightening my clothes, I sat up and asked my guest, "Why are you playing this way?" He replied, " 'The moon is bright, stars are few Crows and magpies are flying south. '6 "Isn't this from the poem by Ts'ao Ts'ao? Westward is Hsia- k'ou; to the east lies Wu-ch'ang.7 The mountains and the river encircle one another; how dense the viridian growth! Yet, is this not the place where Ts'ao was trapped by Chou Yii?8 He had just conquered Ching-chou and sailed down to Chiang-ling9 as he followed the course of the river eastward. His fleet stretched bow to stern for a thousand li; his banners and flags blotted out the sky. As he drank wine by the bank
  • 49. of the river, he lay down his lance and composed this poem. Indeed, he dominated his age, yet where is he now? And what about you and me, SU SHIH 187 conversing here by the riverbank like a fisherman and a woodcutter, joined by fish and shrimp with the deer as our companions? We ride on a boat no bigger than a leaf as we drink to each other out of simple gourds. We exist no longer than mayflies between Heaven and Earth, and are of no more consequence than a kernel in the vast ocean. I grieve that my life is but a moment and envy the Long River's endless flow. If only I could grasp hold of a flying Transcendent and wander with him through the Heavens to embrace the bright moon and live forever. But I realize this cannot be, so I confide these lingering sounds to the sad autumn wind." I said, "Do you really understand the water and the moon? Here, it flows by yet never leaves us; over there, it waxes and wanes without growing or shrinking. If you look at things as changing, then Heaven and Earth do not last for even the blink of an eye. If you look at
  • 50. them as unchanging, then I along with everything am eternal. So why be en- vious? Moreover, each thing within Heaven and Earth has its master. If I did not possess it, then I would not take even a hair of it. However, the pure wind over the river becomes sound when our ears capture it, and the bright moon between the mountains takes on form when our eyes encounter it. There is no prohibition against our acquiring them, and we can use them without ever consuming them. They are from the inexhaustible treasury of the Creator-of-Things, which you and I can enjoy together." My guest became happy and laughed. We washed out the cups and drank again. Soon the food was gone, and the cups and plates were strewn about. We lay down in the boat, leaning against each other for pillows, unaware that it was becoming light in the east. Red Cliff II 1~*~~ (1082) In the tenth month of the same year on the day the moon reached its height [November 7], I walked from the Snow Lodge back toward Lin-kao. 1 Two guests accompanied me as we crossed over Yell ow Clay Slope. Frost and dew had already fallen; the leaves had all
  • 51. dropped off from the trees. Our shadows lay on the ground as we gazed up at the bright moon. We looked around us, delighted by the scene, and sang songs for each other as we walked along. After a while I sighed, "I have guests but no wine, and even if I had wine, there is no food to go along with it. The moon is white, the wind, gentle. But how can we enjoy such a fine evening?" One of the 188 SU SHIH guests replied, "Today at twilight, I cast a net and caught a fish with a large mouth and fine scales. It resembles a Pine River perch. 2 But where can we obtain some wine?" I went back and discussed this with my wife, who said, "There are two gallons of wine which I have been keeping for some time in case you should ever need it." So we took along the wine and the fish and traveled once again to the foot of Red Cliff. The river flowed vociferously, the cleaved banks rose a thousand ch'ih. The mountain was high, the moon small. The water level had fallen, rocks protruded. How long had it been since my
  • 52. last visit? The scene was no longer recognizable! I lifted up my robe and alighted. I made my way among sharp crags, parting the overgrowth to crouch on rocks shaped like tigers and leopards and to climb up trees twisted like horned dragons. I pulled myself up to the precarious nests of falcons and peered down at the hidden palace of the river god P'ing 1. 3 My two guests were unable to follow me this far. I suddenly let out a sharp cry. The plants and trees were startled and shook; mountains resounded, valleys echoed. Winds arose, and the water became agi- tated. For my part, I became hushed and melancholy, then awed and fearful. Then I began to tremble so that I could no longer remain there. I returned, got back on board, and had the boat steered into the main- stream. We let it drift until it came to rest there. By then it was toward midnight. All around us it was deathly si- lent. Suddenly, a solitary crane came toward us across the river from the east. Its wings traced cartwheels in the air. It seemed dressed in a white jacket over a black gown, and let out a long, piercing cry- "chia"-as it swept past our boat and headed west. A short while later the guests left, and I fell asleep. I dreamed of two Taoists clothed in feathers, fluttering about. 4 As they passed by
  • 53. Lin-kao, they greeted me and asked, "Did you enjoy your journey to Red Cliff?" When I asked their names, they looked down without answering. "Oh! Now I understand! Last night, was it not you who called out as you flew by?" The Taoists looked back at me and laughed. And then I suddenly awakened. I opened the door and looked outside but saw no trace of them. 5 Stone Bells Mountain ;Gjj:J.dC. (1084) In 1084, Su Shih was given a slight promotion and transferred from Huang Prefecture to Ju Prefecture. He traveled to his new post by boat along the Long River together with his son, Su Mai (1059-?), stopping 25 Fan Ch'eng-ta (1126-1193) ~,. ...; ...l- ~~ nx.,. ~ Fan Ch'eng-ta, from P'ing-chiang, Wu-chiin (modern Su-chou, Chiang-su), was born into an official family. At the age of seventeen, he was identified as a promising young talent and asked to submit poetry to the Ministry of Rites. In I I 54, he became a Metropolitan
  • 54. Graduate and, two years later, began serving in local posts. Fan was a dedicated Confucian official concerned with the welfare of the people, the military strengthening of the state, and the recovery of the north from the Chin dynasty. By 1166 he had quickly risen to the position of vice-director in the Ministry of Personnel, causing political opponents to claim that he had been promoted above his rank; he was therefore dismissed and sent home. After two years in retirement, he returned to office, gaining the confidence of the Emperor Hsiao-tsung (r. I I62- ll 89) as a member of the irredentist faction. He successfully carried out a diplomatic mission to the Chin in I I70, which resulted in the first of his travel diaries, Grasping the Carriage Reins (Lan-p'ei lu), along with a cycle of seventy-two poems on the events of this journey. He subsequently lost power at court for opposing a favorite of the emperor and again retired in I I7I. Fan returned to public life in I I 73 to serve in Kuang-hsi; he recorded his investigations of the area around Kuei-lin in a local gazetteer and in another travel diary, Riding in the Luan- bird Chariot (Ts'an-luan lu, II73). The following year he served as military commissioner in Szu-ch'uan, where he employed Lu Yu. Returning to the capital in 1177, Fan took over the Ministry ofRites and, in
  • 55. II78, became Examination Administrator and Participant in Determining Government Matters, an important policymaking position. A few months later he was again impeached by a jealous censor. After 213 Fig. 34· Sung Hsii (1 525- ?), Eyebrows Mou11tai11 After a Snowfall (1605}. N anking Museum, Nanking . FAN CH'ENG-TA 215 returning to government in I I So for one final period of service, he retired in n83 owing to ill health; he lived on at Stone Lake (Shih-hu) in the Su-chou area for another ten years. Later canonized as one of the Four Masters of Southern Sung poetry, Fan worked largely in the field-and-garden genre. He brought to its tradition of reclusiveness, assertion of moral purity, and transcendental longings a thorough realism, conveyed through objective observations about moral and social life in the countryside. Some poems have a quality of egoless impersonality and sudden shifts in perspective, reflecting his interest in Ch'an Buddhism. His monumental Gazetteer of Wu-chiin (Wu-chiin chih, I I92-I I93) was
  • 56. considered a model work. In his lyric travel records, he was influenced by the descriptive style of Liu Tsung-yiian and the philosophical attitudes of Su Shih, particularly in two accounts of his outings on Stone Lake. Fan was also regarded as an outstanding calligrapher. Diary of a Boat Trip to Wu (Wu-ch'uan lu) was written following Fan Ch'eng-ta's service in Szu-ch'uan. InJune II77, he set out on his return to Hang-chou at a leisurely pace that enabled him to stop at scenic places along the river route. The following selection describes the IO, I65-foot Eyebrows Mountain (0-mei-shan), located in modern 0-mei District, Szu-ch'uan. One of the four sacred mountains of Buddhism in China, its patron being the Bodhisattva Samantabhadra, it has been a site of religious pilgrimage since the T'ang. Even earlier, during the Eastern Chin, the calligrapher Wang Hsi-chih had viewed it from a nearby mountain and praised its beauty. Fan moored his boat at Chia Prefecture (modern Le-shan, Szu-ch'uan) and spent three days making the seventeen mile ascent to the summit, where pilgrims and sightseers could visit an ancient shrine and view "Buddha's Halo." His descriptive style is clear and reportorial, revealing his curiosity about
  • 57. the observable world and his interest in "the classification of things"; some of his explanations of natural phenomena, though, would be considered unscientific today. From Diary of a Boat Trip to Wu: Eyebrows Mountain ~4ltr~:"'lt.vQ J4 (1177) On the day i-wei [July 24, 1177], the sky cleared after a snowfall .... We passed New Station, Eighty-four Slopes, and Sala Plateau. 1 The wood and leaves of the sa/a-tree resemble the hai-t'ung, and it is also like the yang-mei. 2 Its flowers are red and white, blossoming in spring and 216 FAN CH'ENG-TA summer. It grows only on this mountain. I saw them as soon as I climbed halfway up, but when I reached this point, they covered the whole mountain. In general, all the plants, trees, birds, and insects on Greater Eyebrow Peak differ from those found in the world below. Previously, I had only heard descriptions of them; now I have been able to investigate them for myself. I came in the last month of summer. 3 Several days before, there was a heavy snowfall, and there were still
  • 58. fresh traces of it on the tree leaves. Among the rare plants, there is one that resembles the Eight Transcendents hydrangea, except that it is a deep purple. Another is like the morning glory, but several times larger. Yet another resembles smartweed but is a pale green. I have heard that rare flowers are especially plentiful in spring, but at this sea- son it is cold on the mountain and few can be seen. As for rare herbs, there are so many I could not enumerate them all. The mountain is high and windy, so trees cannot grow tall. Their branches all hang downward. Old moss clings to the trees like disheveled hair, hanging down several tens of feet and touching the ground. There is also the pagoda pine, shaped like a fir but with leaves that are round and small. It, too, cannot attain great height but grows erect in stages, like a pa- goda. They are especially plentiful on the summit. Furthermore, there are no birds at all, probably owing to the mountain's elevation, for they cannot fly this high. From Sala Plateau I passed the Pavilion for Contemplating Buddha, Soft-Grass Plateau, and the Stream for Cleansing Feet before finally arriving at the Temple of the Brilliant Image on the summit. Though it
  • 59. contains several tens of wooden chambers, no one lives there. In the middle is a small chapel dedicated to the Bodhisattva Samantabhadra. 4 I began the climb at the beginning of the hours of mao [5 :oo- 7:00 A.M.]; now, it was already past shen [3:oo-s:oo P.M.]. At first I wore summer linen, but it gradually grew colder as I ascended. At Eighty-four Slopes, it suddenly became quite cold. And when I reached the sum- mit, I had to quickly don a double layer of silk-padded clothes as well as a woolen gown and a camel-hair jacket. This exhausted the clothing I had brought along in the trunks. I wrapped a turban around my head in several layers and put on felt boots. Still, it was shiveringly cold, quite unbearable. So I burned charcoal in a brazier, which I clutched as I sat up straight. There is a spring on the summit, but the water cannot boil rice. The kernels remain hard like grains of sand. I knew that water from ancient ice and snow cannot be used to cook with, 5 so I had a jar of water brought along from down below, and this was enough to sus- tain me. FAN CH'ENG-TA 217 A while passed, then I braved the cold and went up over the
  • 60. Bridge of the Celestial Transcendent to Brilliance Cliff, where I lit some incense. The chapel there is covered with a roofing of bark. The Vice-Grand Councillor Wang Chan-shu6 once had the roof tiled, but the snow and frost seeped in and within a year the tiles had all cracked. Later it was reroofed with bark that at least lasts for two to three years. Someone said to me, "Buddha's Halo always appears at the hours of wu [u:oo A.M.-I:oo P.M.]. Now it is past shen [3:oo-s:oo P.M.]. We had better return to our lodgings and come again tomorrow." While we were hesitating, suddenly clouds arose below the cliff from a valley to the side, just where Thunder Cave Mountain is located. The clouds paraded by vigorously like an honor guard. When they encountered the cliff, they paused for a short while. From the top of the clouds, a grand halo appeared containing several rings of various colors. I stood exactly opposite it and saw an inky shadow in its center, like a Transcendent or a sage astride an elephant. 7 In the time it would take to drink a cup of tea, the halo vanished, while beside it appeared another halo just like the one before. It, too, vanished after a while. From the clouds there then appeared two rays of golden light, which extended along the waist
  • 61. of the cliff. People call it the "Lesser Manifestation." By sunset, the clouds had all dispersed, and the surrounding mountains became quite tranquil. By the second night watch [9:oo-u:oo P.M.], lights appeared all over below the cliff. When viewed from a distance, they seemed to number in the many hundreds, perhaps even a thousand. At night, the cold was intense; I could not stand outside for long. The next day, ping-shen [July 25], I again ascended Brilliance Cliff for the view. Behind the cliff were the many layers of the Mount Min range. Slightly to the north was Tiled House Mountain, located in Y a Prefecture. 8 A bit to the south was Greater Tiled House Mountain, close to the area of Nan-chao. 9 Its shape looked just like a one- room house with a tiled roof. There was also a halo at Lesser Tiled Roof Mountain, known as the "Manifestation of Self-Enlightenment. " 10 Be- hind these mountains are the Snowy Mountains of the Western Re- gion.11 Lofty, rugged, carved, sliced; scores, perhaps a hundred peaks in all. When the rising sun first illuminates them, the snow glistens like shiny silver, shimmering in the light of the dawn. From antiquity to the present, this snow has never melted. These mountains extend all
  • 62. the way to the land of India and to tributary kingdoms along the border for a distance of I don't know how many thousands of li. It looks like it is spread out on a table before one. This spectacular, unique, unsurpassable view was truly the crowning one of my entire life. 218 FAN CH'ENG-TA I returned to the chapel on the cliff to offer up a prayer. Soon, a dense mist arose on all sides, blending everything into a single white- ness. A monk said to me, "This is the 'Silvery World."' After a while, a heavy rain fell and the mist dispersed. The monk said, "This is the 'Rain That Cleanses the Cliff.' 'Buddha's Halo' is about to appear." Flossy clouds once again spread out below the cliff, billowing upward until they reached only several tens of feet below the top. The clouds smoothed themselves out like a floor of jade. There was a sudden rain, and droplets flew about. I looked down at the middle of the cliff- there was a large halo lying on top of the smooth clouds. Encircling it were three rings, each containing blue, yellow, red, and green colors. The center of the halo was empty, bright, dense, and clear. Each ob-
  • 63. server could see his form appear in the empty, bright area without the slightest degree of obscurity, just like a mirror. When one raised one's hands and moved one's legs, the reflection indicated this without show- ing anyone else's form. The monk said, "This is the 'Halo That Captures the Body.'" When this halo vanished, winds arose from the mountains in front and the clouds quickly drifted away. From the midst of the wind and clouds appeared yet another large halo. It stretched across several mountains and contained many unusual hues, all gathered together in a multicolored light. Peaks, plants, and trees were so fresh, gorgeous, brilliant, and glittering that I couldn't look at them directly. When the clouds and mist dispersed, this halo remained to shine alone. People call it the "Pure Manifestation." When Buddha's Halo is about to appear, clouds must gather first, forming what is known as the "Flossy World." It is from out of these clouds that the halo appears. But when it appears without the help of clouds, it is called a "Pure Manifestation" and is extremely rare. After the time it would take to have a meal, the halo gradually shifted westward past the mountain. I glanced to the left above Thunder Cave Mountain and
  • 64. again saw a halo just like the one before, only slightly smaller. After a moment it, too, flew off beyond the mountain, moving over toward the plateau, where it hovered just opposite the cliff. Its colors had all changed, and it became the "Golden Bridge," similar to the Rainbow Bridge over the Wu River12 except that the two ends of this "bridge" were supported by purple clouds. Between the hours of wu [I I :oo A.M.-I:oo P.M.] and wei [1:oo-3:oo P.M.] the clouds all disappeared, and this is called "The Final Scene at the Cliff." Only Golden Bridge re- mained visible until after yu [s:oo-7:oo P.M.], when it vanished. 13 26 Chu Hsi (11J0-12oo) Chu Hsi was the major formulator ofNeo-Confucianism, which absorbed concepts of metaphysics and consciousness from Buddhism and Taoism into traditional Confucian ethics. His comprehensive views on the classics were accepted as orthodox thought by the end of the Southern Sung and became the basis of the examination system when it was reinstated in the late Yiian. During the Ming and Ch'ing dynasties,
  • 65. he was canonized as a Sage and sacrificed to in temples along with Confucius and Mencius. His career, however, followed a pattern similar to that of many officials: public service in a variety of offices alternating with periods of political disfavor. While he lived, there was little indication of the extraordinary veneration he was to be accorded throughout the later Chinese empire. Chu Hsi grew up in Ch'ung-an, Chien-yang, in what is today Fu- chien, in an official family originally from Chiang-hsi. His father was demoted for opposing Ch'in Kuei's appeasement policies and died when Chu Hsi was fourteen; subsequently, Chu Hsi continued to espouse his father's patriotic views and suffered similar punishments during his own career. He earned the Metropolitan Graduate degree in 1 148 and began to serve in local positions. Meanwhile, he attracted disciples and developed his own program of Confucian education. In 1163, under Emperor Hsiao-tsung, he was granted an audience and argued for war against the Chin. Though appointed to a number of positions both in the provinces and in the capital, he often refused to accept appointments because of policy differences, or served only briefly before retiring or being demoted. During a fifty-year career, he spent only nine years in office and about forty days at court.
  • 66. His ~~ influence was greater through the educational institutions he sponsored. 219 Fig. 35· Portrait ofChu Hsi. (n.d .) National Pa lace Museum , Taipei. CHU HSI 221 He helped to restore the White Deer Cave Academy in I I79 while serving in Chiang-hsi and the Academy at the Foothills of the Sacred Mount in I I94 while serving as military commissioner in Hu- nan. By the end of his career in I I95 he had become an edict attendant in the Han-lin Academy, but, after angering the powerful official Han T'o- chou, he was finally impeached. His remaining years were spent back in Chien-yang writing and teaching. Chu Hsi's aesthetics asserted the absolute identity ofliterature and the Tao, in contrast to more conventional formulations, which saw writing as but an expression or vehicle of the Tao. For Chu Hsi,
  • 67. they were one and the same, unified through the moral cultivation of the individual. Similarly, he espoused the view, stated in the "Mao Preface" to The Book of Poetry, that poetry was simply the expression of the moral will. His poems, for which he achieved some note, conveyed an archaistic temperament, employing few allusions or metrical intricacies in favor of direct, uncomplicated emotions and objective observations of the world. His prose, as might be expected, was largely didactic and pragmatic. Among the more influential texts associated with him is the Collected Sayings of Master Chu (Chu-tzu yii- lei), which transmitted his remarks on philosophy and literature. It came to be looked upon as a literary model for its inclusion of colloquial elements that captured a sense of actual speech. The following travel piece is undated, but it must have been written before 1185, when one ofhis traveling companions, Liu P'ing-fu, died. That it has been often anthologized is probably due to the prestige of the writer, for it is a conventional, though well-wrought, travel account. Like many travel narratives, it was originally written in conjunction with poems. Chu Hsi represented his experience of a journey as a linear progress through a world of concrete appearances
  • 68. and sensations with only brief autobiographical and lyric elements. The piece reveals a restrained imagination focused on "the classification of things," recording immediate observations of the environment. The Mountain a Hundred Chang High a~ J.i ~C. After ascending the Mountain a Hundred Chang High 1 for about a mile, I peered down to the right at a deep valley and braced myself on the left against an overhanging cliff. Stones had been stacked to form stairs. I climbed all ten or so of them. The scenic beauty of the moun- tain began from here. 222 CHU HSI I followed more stairs eastward and encountered a small stream; a rock bridge spanned it. Everywhere were aged vines and ancient trees. Although it was the height of summer, it was not hot, even at noon- time. The water was completely clear and deep. It splashed down from higher up with splattering sounds-" chien-chien." I crossed the rock bridge, followed alongside two cliffs, winding my way higher until I reached the outer gate of a temple. It was a small building with three
  • 69. rooms, hardly capable of accommodating ten or so people. Still, from the front it surveyed the stream below; in back, it faced a rock pond. Wind comes wafting through two gorges all day long without respite. Inside the gate, one passes over a pond by another rock bridge. Cross- ing it and turning northward, I climbed up many stone steps to arrive at the temple. The temple itself was an old building of several rooms- small, low, cramped, and narrow-not much to look at. Only its west- ern pavilion offered a scenic view. Water flows out from the valley to the west, then through a fissure in the rock, and shoots out from be- neath the pavilion. Southward, it meets the stream from the valley to the east and flows into the pond. When it leaves the pond, it becomes the small stream mentioned earlier. The pavilion occupies a position upstream, just where the onrushing water and steep rocks confront each other, a most enjoyable site. But a wall was built behind it, so there is nothing further to see. I spent the night upstairs in the pavilion alone. Below my bed was the gurgling of water-"chan-chan"- throughout the evening. After a long while, the sounds became in- creasingly melancholy; it was all quite charming. Exiting through the temple gate eastward ten or so paces, I
  • 70. came upon a rock terrace. Below, it extended to a steep cliff, which was deep, dark, dangerous, and inaccessible. I gazed to the southeast through a dense grove and saw a cascade from a rock cave in front shoot out into the air and then drop down for several tens of feet. The foam was like scattering pearls and exhaled mist: as the sunlight illuminated it, the luster was so striking that I couldn't look at it directly. The terrace occupies an open spot on the southwest of the mountain. In front it greets Reed Peak Mountain, 2 whose single peak soars handsomely while for several hundred li about peaks and pinnacles, high and low, one by one, are displayed before one's eyes. As the sun drew near to the mountains on the west, its twilight rays glowed across the sky. Purple and emerald green intermingled- an in- describable sight. When I arose at dawn and looked down below, white clouds formed a river rising and falling like waves in the ocean. All the mountains, far and near, protruded through the middle. They seemed CHU HSI 223
  • 71. to fly and float, back and forth, now surging, now engulfed. In but a short while, a myriad transformations occurred. East of the terrace, the path ended. Local people have cut stairs into the rock in order to pass. They have placed a shrine to the east of it. In times of drought, they offer up prayers to it. Those who are frightened by the dangerous steepness dare not cross, though beyond this point there is nothing more worth viewing on the mountain anyway. I traveled here with Liu Ch'ung-fu, Liu P'ing-fu, 3 Lii Shu- ching, and my cousin Hsii Chou-pin. We all wrote poems to mark the scenic spots. I also wrote this description of the sequence of sights. Those most worth viewing are the stone stairs, the small stream, the temple gate, the rock terrace, the West Pavilion, and the cascade. Because these places are so distinctive, I composed a short poem to record each one and offer them to my fellow travelers as well as to those who would like to journey here but cannot. RECORDED ON THE-- DAY, IN THE __ MONTH OF THE-- YEAR4
  • 72. COMP 3004 – cuACS Deliverable #2 Due: Tuesday, March 5, 2019 at 8:30 AM (morning) Algorithm Design Document You will design your Animal-Client Matching (ACM) algorithm, as specified in the project description posted in cuLearn, and you will provide a PDF document that describes it. Your document will define, explain, and justify the following: • a minimum of twelve (12) separate and original non-physical attributes to be used by your algorithm for matching animals available for adoption with the clients who wish to adopt them NOTE: a large proportion of binary attributes, such as those with yes/no values, will result in an algorithm that is insufficiently original and complex, and will likely earn a failing grade • the valid range of values for each attribute • a unique set of rules for matching together animal and client profiles, based on the attributes contained in those profiles; the rules must use all the attributes that you define, including a client’s own attributes and their matching preferences • a description of the algorithm detailing how the rules are used to compute the optimal set of matches Your algorithm will be evaluated based on the variety, originality, complexity, and appropriateness of its
  • 73. matching rules and attributes. Algorithm Design Presentation Presentations discussing each team’s ACM algorithm will take place in class on March 5, 7, 12, 14, and possibly into March 19. The projected date each team’s presentation will be decided a few days in advance, but the exact time will be random. All teams are expected to be in the classroom at the start of their presentation day. Each team will be given five (5) minutes to explain and justify their algorithm, including their choice of attributes and matching rules. Each team will submit their presentation slides in cuLearn before the Deliverable #2 due date. Modifications to the presentation slides after the due date and time will be disallowed. Feature Implementation You will implement the following cuACS features, as specified in the project description posted in cuLearn: • Staff/client feature: View all animals (listing and detailed information) • Staff feature: Add animal, with all the animal profile information required by the ACM algorithm • Staff feature: View all clients (listing and detailed information) • Staff feature: Add client, with the basic contact information
  • 74. Your submission must contain a minimum of 25 different animal profiles and 5 client profiles in persistent storage. These profiles must be loaded into memory when the program launches. The animal profiles must include values for all physical attributes, as well as all the attributes defined for the ACM algorithm. The client profiles must include the basic contact information. COMP 3004 -- Winter 2019 cuACS -- Deliverable #2 1/2 Grading Grading breakdown: • Algorithm design document: 40% • Algorithm design presentation: 20% • Feature implementation: 40% View all animals (staff/client) 10% Add animal 10% View all clients 10% Add client 10% Format Documentation deliverables must be submitted as a PDF document. They must be typed and legible, and they must be professional documents, including a cover page, page numbers, table of contents,
  • 75. table of figures, section numbers and names, etc. All diagrams and tables must be introduced and explained in the text. All the text must be in your own words. Copying or pasting from any sources, even cited ones, is strictly disallowed. Documents that do not conform to these specifications will not be graded. Coding deliverables must be delivered as a single tar file consisting of all source code, data files, and configuration scripts, as well as installation, build, and launch instructions in a readme file. Do not provide object files and project executables as part of your submission. Coding submissions that cannot be downloaded into a fresh directory and un-tar’ed, then successfully built with a single command in the course VM, and successfully launched with a single command in the course VM, will not be graded. Submissions without a readme file to explain installation, build, and launch instructions will not be graded. COMP 3004 -- Winter 2019 cuACS -- Deliverable #2 2/2 ./addnewanimalform.cpp #include "addnewanimalform.h" #include "iostream" AddNewAnimalForm::AddNewAnimalForm(QWidget *parent) : QDialog(parent), ui(new Ui::Dialog) { ui->setupUi(this);
  • 76. nameBox = new QLineEdit(); speciesBox = new QLineEdit(); ageBox = new QLineEdit(); ageBox->setValidator(new QIntValidator());//Only ints allowed weightBox = new QLineEdit(); weightBox->setValidator(new QIntValidator());//Only ints allowed sizeBox = new QLineEdit(); colorBox = new QLineEdit(); genderBox = new QComboBox(); //Set up the options for the drop-down menu QStringList genderOptions = QStringList(); genderOptions << "Male" << "Female"; genderBox->addItems(genderOptions); //Now that we've created all the input fields, we add them to the form ui->addForm->addRow(QString("Name:"), nameBox); ui->addForm->addRow(QString("Species:"), speciesBox); ui->addForm->addRow(QString("Gender:"), genderBox); ui->addForm->addRow(QString("Color:"), colorBox); ui->addForm->addRow(QString("Age:"), ageBox); ui->addForm->addRow(QString("Weight(g):"), weightBox); ui->addForm->addRow(QString("Size:"), sizeBox); } AddNewAnimalForm::~AddNewAnimalForm() { delete nameBox; delete speciesBox; delete genderBox; delete colorBox; delete ageBox; delete weightBox; delete sizeBox;
  • 77. delete ui; } void AddNewAnimalForm::accept() { std::string name = nameBox->text().toStdString(); std::string species = speciesBox->text().toStdString(); std::string color = colorBox->text().toStdString(); std::string age = ageBox->text().toStdString(); std::string weight = weightBox->text().toStdString(); std::string gender = genderBox->currentText().toStdString(); std::string size = sizeBox->text().toStdString(); //If all of the fields hold a value, we create a new animal and emit the addNew signal if (!name.empty() && !species.empty() && !color.empty() && !age.empty() && !weight.empty() && !gender.empty() && !size.empty()) { Animal * newAnimal = new Animal(name, species, color, std::stoi(age), std::stoi(weight), gender, size); emit addNew(newAnimal); } //Either way we close the panel emit closePane(); close(); } void AddNewAnimalForm::reject() { emit closePane(); close(); } ./addnewanimalform.h #ifndef ADDNEWANIMALFORM_H
  • 78. #define ADDNEWANIMALFORM_H #include <QWidget> #include <QDialog> #include <QLineEdit> #include <QComboBox> #include "ui_addnewanimalform.h" #include "animal.h" //This is the class for the form that pops down when you click File > Add Animal. addnewanimalform.ui is the .ui file which corresponds to it. class AddNewAnimalForm : public QDialog { Q_OBJECT public: explicit AddNewAnimalForm(QWidget *parent = nullptr); ~AddNewAnimalForm(); signals: void addNew(Animal * animal);//Sent when the user hits 'OK' and successfully adds an animal to the program void closePane();//Sent when the user closes the form by any means public slots: void accept(); //Received when the user hits the OK button void reject(); //Received when the user hits the Cancel button private: Ui::Dialog *ui; //We add these widgets to the FormLayout located in ui, and get user input from them. QLineEdit * nameBox; QLineEdit * ageBox; QLineEdit * colorBox; QLineEdit * weightBox; QLineEdit * sizeBox; QLineEdit * speciesBox;
  • 79. QComboBox * genderBox; }; #endif // ADDNEWANIMALFORM_H ./addnewanimalform.ui Dialog 0 0 400 300 Dialog Qt::Horizontal QDialogButtonBox::Cancel|QDialogButtonBox::Ok
  • 81. ./animal.cpp #include "animal.h" Animal::Animal(int id, std::string &name, std::string &species, std::string &color, int age, int weight, std::string &gender, std::string &size): id(id), name(name), species(species), color(color), age(age), weight(weight), gender(gender), size(size) { } //This constructor is for brand-new animals, for whom we don't have a database ID yet. We set the id to -1 so that we know to assign the proper id later. Animal::Animal(std::string &name, std::string &species, std::string &color, int age, int weight, std::string &gender, std::string &size): Animal(-1, name, species, color, age, weight, gender, size) { } std::string Animal::getName() { return name; }
  • 82. std::string Animal::getSpecies() { return species; } std::string Animal::getColor() { return color; } int Animal::getAge() { return age; } int Animal::getWeight() { return weight; } std::string Animal::getGender() { return gender; } std::string Animal::getSize() { return size; } void Animal::setName(const std::string &value) { name = value; } void Animal::setSpecies(const std::string &value)
  • 83. { species = value; } void Animal::setColor(const std::string &value) { color = value; } void Animal::setAge(int value) { age = value; } void Animal::setWeight(int value) { weight = value; } void Animal::setGender(const std::string &value) { gender = value; } void Animal::setSize(const std::string &value) { size = value; } int Animal::getId() const { return id; } void Animal::setId(int value) {
  • 84. //We can only set the ID if the current ID is less than 0 (meaning, is not a valid database ID) if (id < 0) { id = value; } } ./Animal.db ./animal.h #ifndef ANIMAL_H #define ANIMAL_H #include<string> //A class representing a generic animal. Will probably see significant restructuring as the project continues. Right now, just a container for attributes. class Animal { public: Animal(int id, std::string & name, std::string & species, std::string & color, int age, int weight, std::string & gender, std::string & size); Animal(std::string & name, std::string & species, std::string & color, int age, int weight, std::string & gender, std::string & size); std::string getName(); std::string getSpecies(); std::string getColor(); int getAge(); int getWeight(); std::string getGender(); std::string getSize(); void setName(const std::string &value);
  • 85. void setSpecies(const std::string &value); void setColor(const std::string &value); void setAge(int value); void setWeight(int value); void setGender(const std::string &value); void setSize(const std::string &value); int getId() const; void setId(int value); private: std::string name; std::string species; std::string color; int age; int weight; std::string gender; std::string size; int id; }; #endif // ANIMAL_H ./animaltablemodel.cpp #include "animaltablemodel.h" AnimalTableModel::AnimalTableModel(QObject *parent) {
  • 86. storedParent = parent; animals = std::vector<Animal *>(); } AnimalTableModel::~AnimalTableModel() { foreach (Animal * animal, animals) { delete animal; } } int AnimalTableModel::rowCount(const QModelIndex &parent) const { return animals.size(); } int AnimalTableModel::columnCount(const QModelIndex &parent) const { return 2; } QVariant AnimalTableModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { if (index.column() == 0) { auto name = animals[index.row()]->getName().c_str(); return QString("%1").arg(name); } else if (index.column() == 1) { auto species = animals[index.row()]- >getSpecies().c_str(); return QString("%1").arg(species); }
  • 87. } return QVariant(); } QVariant AnimalTableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::DisplayRole) { if (orientation == Qt::Horizontal) { switch (section) { case 0: return QString("Name"); case 1: return QString("Species"); } } } return QVariant(); } void AnimalTableModel::addItem(Animal *item) { //If the animal's ID is less than or equal to zero, it is not yet in the database, so we add it and retrieve the new ID#. if (item->getId() <= 0) { SqlHandler::addNew(item); } beginInsertRows(QModelIndex(), animals.size(), animals.size()); animals.push_back(item); insertRows(animals.size(), 1); endInsertRows();
  • 88. } //Not currently used, database not supported, largely untested void AnimalTableModel::removeItem(Animal *item) { int index = -1; for (unsigned int i = 0; i < animals.size(); i++) { if (animals[i]->getName() == item->getName()) { index = i; } } if (index < 0) { return; } animals.erase(animals.begin() + index); } std::vector<Animal *> AnimalTableModel::getAnimals() { return animals; } ./animaltablemodel.h #ifndef ANIMALTABLEMODEL_H #define ANIMALTABLEMODEL_H #include <QAbstractTableModel> #include "animal.h" #include "sqlhandler.h" #include <vector>
  • 89. //The Model for the table containing the animals. Displays the name and species, and stores the rest of the data for display elsewhere class AnimalTableModel : public QAbstractTableModel { Q_OBJECT public: AnimalTableModel(QObject *parent); ~AnimalTableModel(); int rowCount(const QModelIndex &parent = QModelIndex()) const ; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; //Function which defines the output to the table QVariant headerData(int section, Qt::Orientation orientation, int role) const; void removeItem(Animal * item); //We have the capability to remove objects from the table but it is not currently used and does not remove from the database std::vector<Animal *> getAnimals(); public slots: void addItem(Animal * item); //Adds an animal to the table and database private: std::vector<Animal *> animals; //A vector containing all of the animals in the table QObject *storedParent; //We store the parent of the model; not currently used }; #endif // ANIMALTABLEMODEL_H ./cuACS.pro
  • 90. #------------------------------------------------- # # Project created by QtCreator 2019-02-08T23:09:20 # #------------------------------------------------- QT += core gui sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = cuACS TEMPLATE = app # The following define makes your compiler emit warnings if you use # any feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += main.cpp mainwindow.cpp
  • 91. animaltablemodel.cpp animal.cpp addnewanimalform.cpp sqlhandler.cpp HEADERS += mainwindow.h animaltablemodel.h animal.h addnewanimalform.h sqlhandler.h FORMS += mainwindow.ui addnewanimalform.ui DISTFILES += Animal.db ./cuACS.pro.user EnvironmentId {c76633c0-7a82-4780-8688-cb14bec9d289} ProjectExplorer.Project.ActiveTarget 0 ProjectExplorer.Project.EditorSettings true false true
  • 101. ./install mkdir --parents -v /opt/cuACS cp --verbose -uR Animal.db $_ chmod --recursive a+w /opt/cuACS qmake make ./main.cpp #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } ./mainwindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle("cuACS 0.01"); //Set up table
  • 102. model = new AnimalTableModel(this); ui->tableView->setModel(model); ui->tableView- >setSelectionBehavior(QAbstractItemView::SelectRows); ui->tableView->horizontalHeader()- >setSectionResizeMode(QHeaderView::Stretch); ui->tableView- >setSelectionMode(QAbstractItemView::SingleSelection); std::vector<Animal *> database = SqlHandler::fetchDatabase(); foreach(Animal * animal, database) { model->addItem(animal); } //Set up details panel detailsPanel = ui->animalDetails; nameBox = new QLineEdit(); speciesBox = new QLineEdit(); ageBox = new QLineEdit(); ageBox->setValidator(new QIntValidator()); weightBox = new QLineEdit(); weightBox->setValidator(new QIntValidator()); sizeBox = new QLineEdit(); colorBox = new QLineEdit(); genderBox = new QComboBox(); QStringList genderOptions = QStringList(); genderOptions << "Male" << "Female"; genderBox->addItems(genderOptions); //Add all the input fields to the form layout detailsPanel->addRow(QString("Name:"), nameBox); detailsPanel->addRow(QString("Species:"), speciesBox); detailsPanel->addRow(QString("Gender:"), genderBox); detailsPanel->addRow(QString("Color:"), colorBox); detailsPanel->addRow(QString("Age:"), ageBox);
  • 103. detailsPanel->addRow(QString("Weight(g):"), weightBox); detailsPanel->addRow(QString("Size:"), sizeBox); //Set up the selectionChanged signal QItemSelectionModel *selectionModel= ui->tableView- >selectionModel(); connect(selectionModel, SIGNAL(selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT(selectionChangedSlot(const QItemSelection &, const QItemSelection &))); //Set up the signals for the details/editing box connect(nameBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(speciesBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(ageBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(weightBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(sizeBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(colorBox, SIGNAL(editingFinished()), this, SLOT(valueUpdatedSlot())); connect(genderBox, SIGNAL(activated(int)), this, SLOT(valueUpdatedSlot())); //Now we hide all the input fields until a selection is made in the table nameBox->hide(); speciesBox->hide(); ageBox->hide(); weightBox->hide(); sizeBox->hide(); colorBox->hide(); genderBox->hide();
  • 104. } MainWindow::~MainWindow() { delete ui; delete nameBox; delete speciesBox; delete genderBox; delete colorBox; delete ageBox; delete weightBox; delete sizeBox; delete model; delete detailsPanel; delete docker; } void MainWindow::removeDocker() { docker->close(); } void MainWindow::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/) { nameBox->show(); speciesBox->show(); ageBox->show(); weightBox->show(); sizeBox->show(); colorBox->show(); genderBox->show(); const QModelIndex index = ui->tableView- >selectionModel()->currentIndex(); currentAnimal = model->getAnimals()[index.row()]; nameBox->setText(QString(currentAnimal-
  • 105. >getName().c_str())); ageBox->setText(QString(std::to_string(currentAnimal- >getAge()).c_str())); speciesBox->setText(QString(currentAnimal- >getSpecies().c_str())); genderBox->setCurrentIndex(genderBox- >findText(QString(currentAnimal->getGender().c_str()))); weightBox->setText(QString(std::to_string(currentAnimal- >getWeight()).c_str())); sizeBox->setText(QString(currentAnimal- >getSize().c_str())); colorBox->setText(QString(currentAnimal- >getColor().c_str())); } void MainWindow::valueUpdatedSlot() { currentAnimal->setName(nameBox->text().toStdString()); currentAnimal->setSpecies(speciesBox- >text().toStdString()); currentAnimal->setAge(std::stoi(ageBox- >text().toStdString())); currentAnimal->setColor(colorBox->text().toStdString()); currentAnimal->setWeight(std::stoi(weightBox- >text().toStdString())); currentAnimal->setGender(genderBox- >currentText().toStdString()); currentAnimal->setSize(sizeBox->text().toStdString()); if (currentAnimal->getId() > 0) { SqlHandler::updateItem(currentAnimal); } } void MainWindow::on_actionAdd_triggered() {
  • 106. docker = new QDockWidget(QString("Add New"), this); AddNewAnimalForm * form = new AddNewAnimalForm(this); docker->setWidget(form); connect(form, SIGNAL(addNew(Animal *)), model, SLOT(addItem(Animal*))); connect(form, SIGNAL(closePane()), this, SLOT(removeDocker())); addDockWidget(Qt::TopDockWidgetArea, docker); } ./mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QLineEdit> #include <QComboBox> #include <QItemSelection> #include <QInputDialog> #include <QFormLayout> #include <QDockWidget> #include "animaltablemodel.h" #include "addnewanimalform.h" #include "sqlhandler.h" //This class defines and controls the main window of the UI. //The ui file corresponding to this class is mainwindow.ui namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT
  • 107. public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); public slots: void removeDocker(); //Removes the docked widget (the add animals widget) because it's no longer needed private: Ui::MainWindow *ui; //These are the input fields on the right which allow the user to edit the sleected animal QComboBox * genderBox; QLineEdit * nameBox; QLineEdit * ageBox; QLineEdit * speciesBox; QLineEdit * colorBox; QLineEdit * weightBox; QLineEdit * sizeBox; //The current animal selected in the table Animal * currentAnimal; //The table model AnimalTableModel * model; //The form layout containing the details/edit fields for the selected animal QFormLayout * detailsPanel; //The widget for adding animals to the database QDockWidget * docker; private slots: void selectionChangedSlot(const QItemSelection & newSelection, const QItemSelection & oldSelection); //Received when the selected item in the table changes void valueUpdatedSlot(); //Received when the value in an input field changes void on_actionAdd_triggered(); //Received when File > Add Animal is clicked on };
  • 109. File Add Animal ./README.md # Carleton University Animal Care System Created for Carleton University's COMP3004 course (taught by Prof. Christine Laurendeau) by Peter MacDonald (100683150), Ibiduneyitayo(101018199), and Nicholas Aubé(101032093) ## Installation To install the software after extracting it from the .tar file, simply run the following command in the directory: ``` sudo bash install ```
  • 110. You will likely be prompted to input your administrator password in order to run the install script with sudo. Local files, such as the animal database, are installed to the directory /opt/cuACS in your file system. If this directory already contains files, they may be overwritten in this process. ## Running To run the software, after installing, run the following command from the same directory: ``` ./cuACS ``` ## Cleanup To clean up the software, run the following command from its directory: ``` sudo bash uninstall ``` Note that this uninstall script will delete the /opt/cuACS directory we are storing local files in. If you wish to retain this directory, you may want to run: ``` make clean ``` Instead. This will clean up the software directory without affecting /opt/cuACS. You will likely be prompted to input your administrator password in order to run the uninstall script with sudo. ## A note for developers
  • 111. When you open the project in QT Creator, it has its own build directory in mind, and does not know to deploy the local files to /opt/cuACS. Either run the installer script yourself, or manually move the files over. ./sqlhandler.cpp #include "sqlhandler.h" const QString SqlHandler::DB_LOCATION = "/opt/cuACS/Animal.db"; QSqlDatabase SqlHandler::db = QSqlDatabase::addDatabase("QSQLITE", "Connection"); std::vector<Animal *> SqlHandler::fetchDatabase() { std::vector<Animal *> returnValue = std::vector<Animal *>(); db.setDatabaseName(DB_LOCATION); if (!db.open()) { qDebug("Error occurred opening the database."); qDebug("%s.", qPrintable(db.lastError().text())); throw "Error opening database."; } QSqlQuery query(db); //Get the properties for all the animals in the table query.prepare("SELECT animal_ID, name, type, color, age, weight_kg, gender, size FROM animal"); if (!query.exec()) { qDebug("Error occurred querying."); qDebug("%s.", qPrintable(db.lastError().text())); db.close(); throw "Error reading database.";
  • 112. } //For each animal, assemble the object in memory from the properties retrieved from the server while (query.next()) { int id = query.value(0).toInt(); std::string name = qPrintable(query.value(1).toString()); std::string type = qPrintable(query.value(2).toString()); std::string color = qPrintable(query.value(3).toString()); int age = query.value(4).toInt(); int weight = query.value(5).toInt(); std::string gender = qPrintable(query.value(6).toString()); std::string size = qPrintable(query.value(7).toString()); returnValue.push_back(new Animal(id, name, type, color, age, weight, gender, size)); } db.close(); return returnValue; } bool SqlHandler::updateItem(Animal * animal) { db.setDatabaseName(DB_LOCATION); if (!db.open()) { qDebug("Error occurred opening the database."); qDebug("%s.", qPrintable(db.lastError().text())); return false; } QSqlQuery query(db); //Update the animal corresponding to our ID in the database with the current property values query.prepare("UPDATE animal SET name=:name, type=:type, color=:color, age=:age, weight_kg=:weight,
  • 113. gender=:gender, size=:size WHERE animal_ID=:id"); query.bindValue(":name", QVariant(animal- >getName().c_str())); query.bindValue(":color", QVariant(animal- >getColor().c_str())); query.bindValue(":type", QVariant(animal- >getSpecies().c_str())); query.bindValue(":age", QVariant(animal->getAge())); query.bindValue(":weight", QVariant(animal->getWeight())); query.bindValue(":gender", QVariant(animal- >getGender().c_str())); query.bindValue(":size", QVariant(animal- >getSize().c_str())); query.bindValue(":id", QVariant(animal->getId())); if (!query.exec()) { qDebug("Error occurred querying."); qDebug("%s.", qPrintable(db.lastError().text())); db.close(); return false; } db.close(); return true; } bool SqlHandler::addNew(Animal * animal) { if (animal->getId() >= 0) { return false; } db.setDatabaseName(DB_LOCATION); if (!db.open()) { qDebug("Error occurred opening the database.");
  • 114. qDebug("%s.", qPrintable(db.lastError().text())); return false; } //Add the animal to the database QSqlQuery query(db); query.prepare("INSERT INTO animal (name, color, type, age, weight_kg, gender, size) VALUES (:name, :color, :type, :age, :weight, :gender, :size)"); query.bindValue(":name", QVariant(animal- >getName().c_str())); query.bindValue(":color", QVariant(animal- >getColor().c_str())); query.bindValue(":type", QVariant(animal- >getSpecies().c_str())); query.bindValue(":age", QVariant(animal->getAge())); query.bindValue(":weight", QVariant(animal->getWeight())); query.bindValue(":gender", QVariant(animal- >getGender().c_str())); query.bindValue(":size", QVariant(animal- >getSize().c_str())); if (!query.exec()) { qDebug("Error occurred inserting."); qDebug("%s.", qPrintable(db.lastError().text())); db.close(); return false; } //Retrieve the auto-generated id from the database for the animal we just put in QSqlQuery idQuery(db); idQuery.prepare("SELECT animal_ID FROM animal WHERE name=:name AND type=:type AND color=:color AND age=:age AND weight_kg=:weight AND gender=:gender AND
  • 115. size=:size"); idQuery.bindValue(":name", QVariant(animal- >getName().c_str())); idQuery.bindValue(":color", QVariant(animal- >getColor().c_str())); idQuery.bindValue(":type", QVariant(animal- >getSpecies().c_str())); idQuery.bindValue(":age", QVariant(animal->getAge())); idQuery.bindValue(":weight", QVariant(animal- >getWeight())); idQuery.bindValue(":gender", QVariant(animal- >getGender().c_str())); idQuery.bindValue(":size", QVariant(animal- >getSize().c_str())); if (!idQuery.exec()) { qDebug("Error occurred querying."); qDebug("%s.", qPrintable(db.lastError().text())); db.close(); return false; } idQuery.next(); //Set the animal object's ID to match the database ID. animal->setId(idQuery.value(0).toInt()); db.close(); return true; } SqlHandler::SqlHandler() { }