How to Extract MPP Metadata Using Java
In order to get MPP file metadata, we’ll use
API which is a feature-rich, powerful and easy to use metadata API for Java platform. You can download its latest version directly from
and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-tasks</artifactId>
<version>version of aspose-tasks API</version>
<classifier>jdk17</classifier>
</dependency>
Steps to Extract Metadata of MPP via Java
- Load MPP using Project Class
- Use respective Class objects like Task, Resource
- Set the relevant properties
- Save the project
System Requirements
Aspose.Tasks for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
- Get latest version of Aspose.Tasks for Java directly from Maven .
Extract Metadata of MPP - Java
long OneSec = 10000000;
long OneMin = 60 * OneSec;
long OneHour = 60 * OneMin;
long OneDayEightHour = 8 * OneHour;
long OneDayTwentyFourHour = 24 * OneHour;
Project project = new Project("NewPrj2010.mpp");
java.util.Calendar calendar = java.util.Calendar.getInstance(TimeZone.getTimeZone("GMT"));
calendar.set(2012, java.util.Calendar.DECEMBER, 7, 0, 0, 0);
Date startDate = calendar.getTime();
calendar.set(2013, java.util.Calendar.DECEMBER, 7, 0, 0, 0);
Date toDate = calendar.getTime();
WorkingTime wt = new WorkingTime();
wt.setFromTime(startDate);
wt.setToTime(toDate);
WeekDay day = project.get(Prj.CALENDAR).getWeekDays().toList().get(1);
day.getWorkingTimes().add(wt);
project.get(Prj.CALENDAR).setName("CHANGED NAME!");
Task task = project.getRootTask().getChildren().add("Task 1");
task.set(Tsk.DURATION_FORMAT, TimeUnitType.Day);
task.set(Tsk.DURATION, project.getDuration(3));
task.set(Tsk.CONTACT, "Rsc 1");
// new fields
task.set(Tsk.IS_MARKED, true);
task.set(Tsk.IGNORE_WARNINGS, true);
Task task2 = project.getRootTask().getChildren().add("Task 2");
task2.set(Tsk.DURATION_FORMAT, TimeUnitType.Day);
task2.set(Tsk.CONTACT, "Rsc 2");
project.getTaskLinks().add(task, task2, TaskLinkType.FinishToStart, project.getDuration(-1, TimeUnitType.Day));
calendar.set(2013, java.util.Calendar.DECEMBER, 13, 9, 0, 0);
startDate = calendar.getTime();
project.set(Prj.START_DATE, startDate);
Resource rsc = project.getResources().add("Rsc 1");
rsc.set(Rsc.TYPE, ResourceType.Work);
rsc.set(Rsc.INITIALS, "WR");
rsc.set(Rsc.ACCRUE_AT, CostAccrualType.Prorated);
rsc.set(Rsc.MAX_UNITS, 1d);
rsc.set(Rsc.CODE, "Code 1");
rsc.set(Rsc.GROUP, "Workers");
rsc.set(Rsc.E_MAIL_ADDRESS, "This email address is being protected from spambots. You need JavaScript enabled to view it.");
rsc.set(Rsc.WINDOWS_USER_ACCOUNT, "user_acc1");
rsc.set(Rsc.IS_GENERIC, new NullableBool(true));
rsc.set(Rsc.ACCRUE_AT, CostAccrualType.End);
rsc.set(Rsc.STANDARD_RATE, BigDecimal.valueOf(10));
rsc.set(Rsc.STANDARD_RATE_FORMAT, RateFormatType.Day);
rsc.set(Rsc.OVERTIME_RATE, BigDecimal.valueOf(15));
rsc.set(Rsc.OVERTIME_RATE_FORMAT, RateFormatType.Hour);
rsc.set(Rsc.IS_TEAM_ASSIGNMENT_POOL, true);
rsc.set(Rsc.COST_CENTER, "Cost Center 1");
ResourceAssignment assn = project.getResourceAssignments().add(task, rsc);
assn.set(Asn.UID, 1);
assn.set(Asn.WORK, task.get(Tsk.DURATION));
assn.set(Asn.REMAINING_WORK, assn.get(Asn.WORK));
assn.set(Asn.REGULAR_WORK, assn.get(Asn.WORK));
task.set(Tsk.WORK, assn.get(Asn.WORK));
rsc.set(Rsc.WORK, task.get(Tsk.WORK));
assn.set(Asn.START, task.get(Tsk.START));
assn.set(Asn.FINISH, task.get(Tsk.FINISH));
// Add extended attribute for project and task
ExtendedAttributeDefinition attr = ExtendedAttributeDefinition.createTaskDefinition(CustomFieldType.Flag,
ExtendedAttributeTask.Flag1, "MyFlagField");
project.getExtendedAttributes().add(attr);
ExtendedAttribute taskAttr = attr.createExtendedAttribute();
taskAttr.setFlagValue(true);
task2.getExtendedAttributes().add(taskAttr);
project.save("updated.mpp", SaveFileFormat.MPP);
About Aspose.Tasks for Java API
Aspose.Tasks is a Microsoft Project API to view and convert project documents. One can load, create, modify and render Microsoft Project files to Primavera, Excel, PDF, HTML, images and XML formats. Aspose.Tasks is a standalone API and does not require Microsoft Project or any other software to be installed.Extract Metadata of MPP via Online App
View & edit Metadata to MPP documents by using our Live Demos with following benefits.
MPP What is MPP File Format
A file with MPP extension is Microsoft Project data file that stores information related to project management in an integrated manner. It is proprietary file format developed by Microsoft as file format for Microsoft Project (MSP) which is a project management application software. Besides MPP, MSP supports other file formats as well like project XML schema. Several APIs and applications provide the facility to convert MPP file format to others. Microsoft now has online Project Server where project management files can be uploaded for collaboration by multiple users.