Subversion Repositories XServices

Compare Revisions

No changes between revisions

Ignore whitespace Rev 29 → Rev 30

/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketDataHandler.java
0,0 → 1,175
/*
* Mylyn Connector for Serena Business Mashups
* Copyright 2010 Brian Rosenberger (Brutex Network)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Serena, TeamTrack and Serena Business Mashup are
* registered trademarks of SERENA Software Inc.
*/
package net.brutex.mylyn.sbmconnector.core;
 
import java.util.Set;
 
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
import net.brutex.mylyn.sbmconnector.core.model.SBMNote;
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
import net.brutex.sbm.wsclient.TTItem;
 
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
import org.eclipse.mylyn.tasks.core.data.TaskData;
 
/**
* The Class SBMTicketDataHandler.
*/
public class SBMTicketDataHandler extends AbstractTaskDataHandler {
 
/** The connector. */
private final SBMRepositoryConnector connector;
/**
* Instantiates a new SBM ticket data handler.
*
* @param connector the connector
*/
public SBMTicketDataHandler(SBMRepositoryConnector connector) {
this.connector = connector;
}
/* (non-Javadoc)
* @see org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#getAttributeMapper(org.eclipse.mylyn.tasks.core.TaskRepository)
*/
@Override
public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) {
return new SBMTicketAttributeMapper(taskRepository);
}
 
/* (non-Javadoc)
* @see org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#initializeTaskData(org.eclipse.mylyn.tasks.core.TaskRepository, org.eclipse.mylyn.tasks.core.data.TaskData, org.eclipse.mylyn.tasks.core.ITaskMapping, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public boolean initializeTaskData(TaskRepository repository, TaskData taskData,
ITaskMapping initializationData, IProgressMonitor monitor)
throws CoreException {
/*TaskAttribute attribute = taskData.getRoot().createAttribute(SBMStaticFields.TITLE);
attribute.getMetaData().setReadOnly(false).setType(TaskAttribute.TYPE_SHORT_TEXT).setLabel("Summary:");
 
/*attribute = taskData.getRoot().createAttribute(SBMStaticFields.DESCRIPTION);
attribute.getMetaData().setReadOnly(false).setType(TaskAttribute.TYPE_LONG_TEXT).setLabel("Description:");
 
attribute = taskData.getRoot().createAttribute(SBMStaticFields.SUBMITDATE);
attribute.getMetaData().setReadOnly(false).setType(TaskAttribute.TYPE_DATETIME).setLabel("Create Date:");
 
 
if (!taskData.isNew()) {
attribute = taskData.getRoot().createAttribute(TaskAttribute.TASK_URL);
attribute.getMetaData().setReadOnly(true).setKind(TaskAttribute.KIND_DEFAULT).setType(
TaskAttribute.TYPE_URL).setLabel("Location:");
File file = client.getTask(taskData.getTaskId(), monitor);
try {
attribute.setValue(file.toURI().toURL().toString());
} catch (MalformedURLException e) {
}
}
 
attribute = taskData.getRoot().createAttribute(TaskAttribute.PRODUCT);
attribute.getMetaData().setReadOnly(false).setKind(TaskAttribute.KIND_DEFAULT).setType(
TaskAttribute.TYPE_SINGLE_SELECT).setLabel("Project");
*/
taskData.setPartial(true);
return true;
}
 
/* (non-Javadoc)
* @see org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#postTaskData(org.eclipse.mylyn.tasks.core.TaskRepository, org.eclipse.mylyn.tasks.core.data.TaskData, java.util.Set, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public RepositoryResponse postTaskData(TaskRepository repository,
TaskData taskData, Set<TaskAttribute> oldAttributes,
IProgressMonitor monitor) throws CoreException {
// TODO Auto-generated method stub
return null;
}
/**
* Convert.
*
* @param repository the repository
* @param ttitem the ttitem
* @param monitor the monitor
* @return the task data
* @throws CoreException the core exception
*/
public TaskData convert(TaskRepository repository, TTItem ttitem, IProgressMonitor monitor)
throws CoreException {
TaskData data = new TaskData(new SBMTicketAttributeMapper(repository),
SBMConnectorPlugin.CONNECTOR_KIND,
repository.getRepositoryUrl(),
ttitem.getGenericItem().getValue().getItemID().getValue());
initializeTaskData(repository, data, null, monitor);
// Create Fields for all the generic SBM (system) fields
for (SBMTicketAttribute f : SBMTicketAttribute.values()) {
TaskAttribute attr;
if(f.getTaskName()!=null) {
attr = data.getRoot().createMappedAttribute(f.getTaskName());
} else {
attr = data.getRoot().createAttribute(f.getSBMName());
}
try {
SBMStaticFields.valueOf(f.getSBMName()); //check if in static field list
attr.getMetaData().setReadOnly(true);
} catch (IllegalArgumentException e) {
attr.getMetaData().setReadOnly(false);
}
attr.getMetaData().setType(f.getTaskType());
attr.getMetaData().setLabel(SBMRepositoryConnector.getClient(repository).getFieldLabel(ttitem, f.getSBMName()));
if(f.isVisible()) {
attr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
} else {
attr.getMetaData().setKind(null);
}
attr.setValue(SBMRepositoryConnector.getClient(repository).getFieldValue(ttitem, f.getSBMName()));
}
//Custom fields
TaskAttribute custom = data.getRoot().createAttribute("BLIBLABLUB");
custom.getMetaData().setType(TaskAttribute.TYPE_BOOLEAN);
custom.getMetaData().setLabel("BIILLALLLLLLLL");
custom.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
custom.setValue("roger");
//Notes
for(SBMNote n : SBMRepositoryConnector.getClient(repository).getNotes(ttitem)) {
TaskCommentMapper mapper = new TaskCommentMapper();
mapper.setCommentId(n.getId());
mapper.setNumber(Integer.valueOf(n.getId()));
mapper.setText(n.getText());
mapper.setCreationDate(n.getCreation());
TaskAttribute a = data.getRoot().createAttribute("NOTE"+n.getId());
mapper.applyTo(a);
}
data.setPartial(false);
return data;
}
}
Property changes:
Added: svn:mime-type
+text/plain
\ No newline at end of property