Often, when I am teaching Introduction to Programming ArcObjects using the Java Platform I get questions asking me how to do something. In particular, a lot of questions come up with respect to the Geodatabase API. In this article, I’d like to focus on one of the more commonly asked questions I get asked while teaching introductory level programming classes: How to Setup Coded Value Domains!
Before we explore the code for creating coded value domains inside a geodatabase, let’s look at why these domains are valuable to developers. Probably one of the most common errors inside a database is typos. It’s really nice when we, as developers, can eliminate these typos or errors at the time the data is entered into the database at creation or while it is being maintained, right? Well, one such tool that we have in our arsenal is coded value domains. There are also range domains and subtypes, stay tuned for future blog postings (hint, hint…). Domains allow us to pre-define an allowable set of values for a given attribute (i.e. field, column) in our geodatabase. Why is this important? Well, from the end user’s perspective, they no longer need to type in the value upon data creation or when they update information in a database. They will actually have a drop down box that will show them the set of possible options to choose from, thus eliminating the possibility of typos. This gives us greater confidence in the integrity of our databases; however, it’s still possible for an end user to select an incorrect value (but at least it will be spelled correctly, right?).
The question then becomes, “Well, how do I write code to achieve this functionality?” The answer is simple and can be understood in the following 3 step workflow:
Step 1: Instantiate the coded value domain class
Step 2: Add the domain to the geodatabase (remember that domains are a property of the geodatabase)
Step 3: Apply the domain to the field of interest
These steps give a high-level overview of exactly what we will replicate in code below.
The following example is going to use a highway network for the entire United States. The data set can actually be found in your samples > data folder that is installed with your Engine SDK. You can also see the full source code posted on the code gallery at the following location. In this scenario, we have an attribute titled “ADMIN_CLASS”, which represents an Administration Classificaiton for the different types of highways we have represented in our dataset. For this example, there are three categories that will be represented with our coded value domain. First, INT represents Interstate. Second, SHW, represents State Highway. Finally, UHW, represents US Highway. The code snippet below will show snippets of code that are used to build this coded value domain and apply it to a field within a feature class inside a geodatabase.
Step 1: Instantiate the coded value domain class.
CodedValueDomain codedValueDomain = new CodedValueDomain();
codedValueDomain.addCode(“SHW”, “State Highway”);
codedValueDomain.addCode(“UHW”, “US Highway”);
In this step, we simply instantiate our coded value domain and add the codes.
Step 2: Add the domain to the Geodatabase
In this step, the workspace object is pointing to our geodatabase of interest (see code gallery example for details in the code).
Step 3: Apply the domain to the field of interest.
//Get the attributes from the feature class
Fields fields = (Fields) featureClass.getFields();
//Get the index position of admin. class. field
//Get the field to apply the domain
//Code to check that field and domain have the same data type…
//Apply domain to the field
In this step, we need to get the fields from the feature class to figure out what the index position is of the field we wish to apply the domain to. We then use the findField() to retrieve the index position and use that index position to retrieve the field object representing the administration classification attribute. After doing some checks in the code, we finally set our domain to the field using the alterDomain() on the feature class.
That’s it for building your very own coded value domain. Hope you find this useful for defining and setting up your own domains in your editing applications. Next time, I’ll talk about range domains and shortly after subtypes to add even more to your arsenal when trying to keep your database integrity.
If you’re a developer and you’re headed to the User Conference this year, here’s a “cheat sheet” of the sessions, activities and events that you might be interested in.
The links below have search filters set so you can browse quickly. Enjoy!
Sessions – Learn
Pre-conference Sessions (all day)
- ArcGIS Server for .NET Developers
- Introduction to ArcGIS Mobile SDK
- Getting Started with ArcObjects
- Extending ArcGIS Desktop with the Microsoft .NET Framework
- Building Solutions with ArcGIS Engine and .NET
- ArcGIS Server for .NET Developers
- Developing Web Applications with Java
- Python Scripting – An Introduction
- Python Scripting – Advanced Techniques
- Showcase Software Island – Desktop Developer Demo Theater
- Showcase Software Island – Mobile GIS – Demo Theater
- Showcase Software Island – ArcGIS Engine and WPF: Tips & Tricks
- Showcase Software Island – ArcGIS Engine Application Deployment
- Showcase Software Island - GIS and Web 2.0 Application Developmen
- Showcase Software Island – Programming wth the Geodatabase API (Part I and Part II)
- CJMTK Developer Experiences
- ArcGIS Engine: Creating Focused Applications for Non-GIS Professionals
- ArcGIS Server Implementations in State and Local Governments
Special Interest Groups Meetings (All)
- Supporting the Lone GIS Professional
- Java Developers Special Interest Group Meeting
- Adobe Flex Special Interest Group
- Microsoft .NET Special Interest Group Meetng
- ESRI’s Support for Open Standards SIG
- Microsoft SQL Server SIG
Islands – Talk to developers
The ESRI development teams are always available to answer questions at the product and developer islands. We definitely recommend that you visit the islands if you want to chat with ESRI staff about developer products, directions, tools and SDKs or ask specific questions about your own development projects.
Technical Support Island – Get questions answered
This is another great developer resource. You can walk up and schedule an appointment with ESRI Support and other technical staff to get answers to your developer-related questions.
User Software Applications Fair – Show your applications
If you developed an application for your organization, you might be interested in this contest to showcase your application. The fair runs Tues-Thursday and there are three categories to enter:
- Embedded GIS (Component-based applications e.g. ArcGIS Engine)
- Desktop (Applications that extend existing applications e.g. ArcMap extensions)
- Web-based (Web browser applications e.g. ArcGIS Server API)
When I entered college at UCLA, I remember that they had a weekend orientation for incoming freshmen. It was held in the summer before the fall quarter was to begin. It was great – you got to meet other incoming freshmen, make friends, and learn about the processes and procedures. I am not sure I would have ever figured out how to enroll in classes without the help of the orientation. The information was available in manuals and guides but it wasn’t in a form that was easily understood by incoming freshmen and it wasn’t easy to find the information.
That’s what we are trying to do at the Java Resource Center. We have a great community of Java developers and a ton of great information available for Java developers but we have never had an orientation that gets you started. On the Java Resource center we have striven to use language that Java Developers will understand and take you to the content for the most common tasks.
Let me take you through the some of the highlights of the Java Resource Center:
- The ArcGIS Java Blog is an opportunity for us at ESRI to share best practices, solicit your feedback, and highlight product features that hopefully will make your life easier.
- The Help tab points you to the latest documentation that’s relevant for Java developers. I personally have this one bookmarked.
- The welcome page is the page that should help get you oriented, leading you to the resources you need to build web apps, consume soap services, build Swing apps, and extend ArcGIS.
- The Communities tab takes you to the existing communities we have for the ArcGIS Server Web ADF and ArcGIS Engine. There you will find a code gallery where developers like you are sharing their code, a media gallery from presentations we have given, and forums to get answers to questions.
To complete the welcome to the Java Resouce Center I would like to share a photo of a lot of the development folks working on Java and Unix products at ESRI.
The US economic recovery stimulus plan is underway and Recovery.gov is the online vehicle for keeping everything transparent to the public. This kind of proactive openness from government is refreshing and confidence building.
But transparency works both ways. Next week (starting April 27th) the Recovery Accountability and Transparency Board wants to hear from the IT community. They want more ideas on how the Recovery.gov site can be improved with information technology.
From their site:
“What ideas, tools, and approaches can make Recovery.gov a place where all citizens can transparently monitor the expenditure and use of recovery funds?”
The front page suggests you can mark your calendars and “check back for the web link”.
As GIS professionals and developers, we know how this technology can be used to collect, manage, analyze, display, work with, and disseminate spatial information. We know how to process data, then present it effectively to the user, giving them simple intuitive tools for seeing what they want to see quickly.
In short, YOU know what can be added to Recovery.gov to make it better in these ways. Jump in and tell them how. And then vote on the ideas. Represent your interests and those of the GIS community.
Take the conversation beyond simply web mapping and visualization. That’s a powerful front-end, but GIS is the engine to help determine what to visualize. Talk about the need for open standards for interoperability, quality data, geographic analysis, modeling, system architecture, and engaging in geospatial workflows that GIS professionals know so well. Describe how for decades GIS has been a key part of the strong foundation for open government, transparency, and accountability.
State and local governments have already started. Maryland is one example of a state leading the way.
Here are ESRI’s ideas and position on how GIS can best help. This is what ESRI will be bringing to the conversation.
Crisis and need feed creativity and innovation, both powerful traits of Americans throughout history.
As these systems are implemented connecting all levels of government, this work also clearly provides new business opportunities for firms doing GIS, especially developers.
What a great way to get involved! Now is the time. Be heard.
1. What each state is doing
2. Facebook Group: Recovery Dialogue: IT Solutions
- EDN Team
Many thanks to the more than 200 attendees who took the time to answer the DevSummit post conference survey. We had a lot of valuable feedback that was both positive and negative for various items at the conference. As for the open-ended questions, we received over 600 unique comments and suggestions. In the end, this feedback will only make next year’s conference even better!
Here are some areas you identified that need improvement:
- There weren’t enough ArcGIS Desktop/non-Web developer sessions
- Need more advanced sessions describing how-to’s and lessons learned
- The level and depth of PreSummit session content needs to be reexamined
- Try not to cram too much material into the sessions
- Internet connectivity access could have been better
Some areas that you thought went well:
- The vast majority of attendees (99.5%) would recommend the DevSummit to a colleague
- Many positive comments about direct access to development teams and other ESRI staff
- The Keynote speaker David Chappell was a huge hit
- The User presentations were very positively received and well attended
- Networking opportunities with other developers
Since the technical sessions are always one of the most valuable resources at the conference, here’s a graph showing what you said about the value of the session content.
We also we received a lot of positive feedback from developers who weren’t able to attend that benefited from information being tweeted by people at the conference. If you missed it, the Twitter account for the summit is @ESRIDevSummit and the hashtag is #devsummit if you want to continue to follow the before, during or after conversations. So, keep your eyes open for more of this type of activity at future conferences, such as the User Conference in San Diego.
Thanks again to all who attended, and if you have something additional to share that will benefit the planning for next year please post a comment.
We would like to introduce this new blog series for the ArcGIS Resource Centers.
This series focuses specifically on the Resource Center Code Galleries. It will cover a wide range of topics including tips and tricks on how to use the galleries, posts highlighting new content, website updates, and hints on how to work with the galleries more effectively.
We’ll also be showcasing some of the best entries here as well, so be sure to stay tuned.
Let’s first get started with a little Q/A.
The code galleries are an online collaboration tool that you can use to share code and exchange ideas with others in the community.
If you browse the entries, you’ll find they contain a wide range of applications and samples. Some are short, specific examples of how to accomplish a given task, while others are more elaborate solutions to real-world problems. Others include code for applications that were shown in presentations at the DevSummit .
In total, there are 16 galleries available for a number of different developer communities:
ArcGIS Desktop and Engine: .NET Java
ArcGIS Mobile: .NET
Geoprocessing: Model and Script
Business Analyst Extension: Desktop Server
Water Utilities: Template
1. Navigate to one of the Code Galleries above.
2. Select a field (name, rating, date added…) to sort the entries.
3. Select the entry itself to get more information.
1. Navigate to one of the Code Galleries.
2. Type in a key word in the Search box at the top.
3. Filter your results by selecting the “Code Gallery” node.
1. Find the sample of interest.
2. If the “View it Live” link is available, click on the link.
Tip: This feature is only enabled if the author who uploaded the entry specified a URL to the application online or a URL to a video that demonstrates how the application works.
1. Find the sample of interest.
2. Click on the download link.
1. Package all of your code, data and a Readme.txt file in one .zip file (max size 30 MB).
2. Go to the appropriate code gallery and create a new entry.
3. Fill out the information for your submission (title, description and requirements…) and submit.
Tip: You will need to create or login to your ESRI Global Account to upload a sample. If you don’t have one, go here.
Tip: If you download code, you might also want to subscribe to the RSS feed so you can be notified of any new comments! Authors often post helpful information here or they’ll make a post when changes are made to the code or new versions are available.
Whether you are just browsing for a solution or you would like the upload and share something with the community, the code galleries are an important resource for everyone.
Tip: If you want to know when new entries are made, be sure to subscribe to the RSS feeds for each gallery so you are notified automatically.
Lastly, if you have any feedback on the galleries, feel free to leave them on the gallery pages themselves or on this post as well.
Thank you for participating in the last survey. When the final scores were tallied, the Technical Sessions were voted the most valuable, followed by the User Sessions, Plenary Sessions, Presummit Seminars and Demo Theaters. We were glad to see the User Sessions were highly valued this year! Hopefully we can offer more next year.
The next poll is coming soon.
We are proud to announce that all of the technical session recordings are now posted online and available for viewing. You’ll find the recordings in two locations:
Resource Centers: The Media Galleries provide the full session descriptions, videos, and links to PowerPoints and code (if applicable) for each presentation. The videos are categorized by the type of community you are in; for example, ArcGIS Desktop > DS2009: Introduction to ESRI’s Developer Technologies.
- DevSummit Proceedings: The Developer Summit 2009 proceedings page provides a master list of all of the recordings. Each entry links back to the associated video and media in the Media Gallery.If you are looking for a particular video by name, you might find it helpful to search this page first.
Three user presentations are also viewable, and more will be uploaded this week. We’ll keep you posted as they become available. Here’s what’s ready today:
Using OpenLayers with ArcGIS Server REST API, presented by James Fee
Building RESTful Apps and Services Using MVC, presented by Brian Noyle
Unit Testing 101: Building Testable Applications, presented by Dave Bouwman
Keep in mind, once you are in the Media Gallery you have two viewing options. You can either use the embedded Flash Player to view the video at 800 x 600, or you can download the WMV file and watch it locally with the Windows Media Player at a slightly higher resolution of 1024×768.
Thanks again for your patience and we hope you find these helpful!
The “ArcObjects Development Blog” has been renamed and is now the “ArcGIS Developer Blog”.
In this blog, you can expect to find similar posts, but they’ll now have a wider “ArcGIS developer” focus. This means you’ll find more developer content in the form of How To<’>s and Did you know articles, resource summaries, and highlights about activity in the ArcGIS developer community.
You’ll also be happy to know that the RSS feed hasn’t changed, so there’s no need to re-subscribe.
As always, we encourage feedback, so feel free to leave suggestions for future articles as well as comments on posts.
We’ll also be posting a number of new ArcGIS developer polls, so stay tuned.
Thanks in advance for participating in the online ArcGIS developer community.
We know you are anxious to see this year’s DevSummit videos, so we wanted to give you a status report of where we are. We have just published a number of videos in the Media Galleries and we are still processing a number of others. We are also still linking the videos to the code galleries, so we appreciate your patience as we get everything wired up for you.
In the galleries you will find following types of videos:
- Plenary session
- PreSummit sessions
- Technical sessions
- User sessions
- Demo Theaters*
* Since the demo theaters weren’t recorded, we have made them available as automated “slide shows”, but they do not have audio.
If you don’t see the video you are looking, for then we recommend subscribing to the RSS feed in the Media Gallery of interest to be notified automatically notified of updates. We expect it will take a week or two to get all of them uploaded.
Lastly, when you are through watching a video, don’t forget to rate and leave comments!
Enjoy and thanks again for your patience.