public synchronized void addJob( String jobName, String carteObjectId, Job job, JobConfiguration jobConfiguration ) { CarteObjectEntry entry = new CarteObjectEntry( jobName, carteObjectId ); jobMap.put( entry, job ); configurationMap.put( entry, jobConfiguration ); }
public int compareTo( CarteObjectEntry o ) { return compare( this, o ); }
job = null; } else { id = entry.getId(); job = getJobMap().getJob( entry ); entry = new CarteObjectEntry( jobName, id ); job = getJobMap().getJob( entry );
public synchronized CarteObjectEntry getFirstCarteObjectEntry( String jobName ) { for ( CarteObjectEntry key : jobMap.keySet() ) { if ( key.getName().equals( jobName ) ) { return key; } } return null; }
@Override public boolean equals( Object obj ) { if ( !( obj instanceof CarteObjectEntry ) ) { return false; } if ( obj == this ) { return true; } CarteObjectEntry entry = (CarteObjectEntry) obj; return entry.getId().equals( id ); }
@Override public int compare( CarteObjectEntry o1, CarteObjectEntry o2 ) { Job t1 = getJobMap().getJob( o1 ); Job t2 = getJobMap().getJob( o2 ); Date d1 = t1.getLogDate(); Date d2 = t2.getLogDate(); // if both jobs have last log date, desc sort by log date if ( d1 != null && d2 != null ) { int logDateCompare = d2.compareTo( d1 ); if ( logDateCompare != 0 ) { return logDateCompare; } } return o1.compareTo( o2 ); } };
trans = null; } else { id = entry.getId(); trans = getTransformationMap().getTransformation( entry ); entry = new CarteObjectEntry( transName, id ); trans = getTransformationMap().getTransformation( entry );
public CarteObjectEntry getFirstCarteObjectEntry( String transName ) { for ( CarteObjectEntry key : transMap.keySet() ) { if ( key.getName().equals( transName ) ) { return key; } } return null; }
@GET @Path( "/jobs/detailed" ) @Produces( { MediaType.APPLICATION_JSON } ) public List<JobStatus> getJobsDetails() { List<CarteObjectEntry> jobEntries = CarteSingleton.getInstance().getJobMap().getJobObjects(); List<JobStatus> details = new ArrayList<JobStatus>(); JobResource jobRes = new JobResource(); for ( CarteObjectEntry entry : jobEntries ) { details.add( jobRes.getJobStatus( entry.getId() ) ); } return details; }
@Override public int compare( CarteObjectEntry o1, CarteObjectEntry o2 ) { Trans t1 = getTransformationMap().getTransformation( o1 ); Trans t2 = getTransformationMap().getTransformation( o2 ); Date d1 = t1.getLogDate(); Date d2 = t2.getLogDate(); // if both transformations have last log date, desc sort by log date if ( d1 != null && d2 != null ) { int logDateCompare = d2.compareTo( d1 ); if ( logDateCompare != 0 ) { return logDateCompare; } } return o1.compareTo( o2 ); } };
trans = null; } else { id = entry.getId(); trans = getTransformationMap().getTransformation( entry ); entry = new CarteObjectEntry( transName, id ); trans = getTransformationMap().getTransformation( entry );
@GET @Path( "/status/{id : .+}" ) @Produces( { MediaType.APPLICATION_JSON } ) public JobStatus getJobStatus( @PathParam( "id" ) String id ) { JobStatus status = new JobStatus(); // find job Job job = CarteResource.getJob( id ); CarteObjectEntry entry = CarteResource.getCarteObjectEntry( id ); status.setId( entry.getId() ); status.setName( entry.getName() ); status.setStatus( job.getStatus() ); return status; }
/** * @param transformationName * @return The first transformation configuration with the specified name */ public TransConfiguration getConfiguration( String transformationName ) { for ( CarteObjectEntry entry : transMap.keySet() ) { if ( entry.getName().equals( transformationName ) ) { return transMap.get( entry ).getConfiguration(); } } return null; }
/** * Add a transformation to the map * * @param transformationName * The name of the transformation to add * @param containerObjectId * the unique ID of the transformation in this container. * @param trans * The transformation to add * @param transConfiguration * the transformation configuration to add */ public void addTransformation( String transformationName, String containerObjectId, Trans trans, TransConfiguration transConfiguration ) { CarteObjectEntry entry = new CarteObjectEntry( transformationName, containerObjectId ); transMap.put( entry, new TransData( trans, transConfiguration ) ); }
@GET @Path( "/transformations/detailed" ) @Produces( { MediaType.APPLICATION_JSON } ) public List<TransformationStatus> getTransformationsDetails() { List<CarteObjectEntry> transEntries = CarteSingleton.getInstance().getTransformationMap().getTransformationObjects(); List<TransformationStatus> details = new ArrayList<TransformationStatus>(); TransformationResource transRes = new TransformationResource(); for ( CarteObjectEntry entry : transEntries ) { details.add( transRes.getTransformationStatus( entry.getId() ) ); } return details; }
job = null; } else { id = entry.getId(); job = getJobMap().getJob( entry ); entry = new CarteObjectEntry( jobName, id ); job = getJobMap().getJob( entry ); if ( job != null ) {
@GET @Path( "/status/{id : .+}" ) @Produces( { MediaType.APPLICATION_JSON } ) public TransformationStatus getTransformationStatus( @PathParam( "id" ) String id ) { TransformationStatus status = new TransformationStatus(); // find trans Trans trans = CarteResource.getTransformation( id ); CarteObjectEntry entry = CarteResource.getCarteObjectEntry( id ); status.setId( entry.getId() ); status.setName( entry.getName() ); status.setStatus( trans.getStatus() ); for ( int i = 0; i < trans.nrSteps(); i++ ) { StepInterface step = trans.getRunThread( i ); if ( ( step.isRunning() ) || step.getStatus() != StepExecutionStatus.STATUS_EMPTY ) { StepStatus stepStatus = new StepStatus( step ); status.addStepStatus( stepStatus ); } } return status; }
public synchronized JobConfiguration getConfiguration( String jobName ) { for ( CarteObjectEntry entry : configurationMap.keySet() ) { if ( entry.getName().equals( jobName ) ) { return getConfiguration( entry ); } } return null; }
public synchronized void registerJob( Job job, JobConfiguration jobConfiguration ) { job.setContainerObjectId( UUID.randomUUID().toString() ); CarteObjectEntry entry = new CarteObjectEntry( job.getJobMeta().getName(), job.getContainerObjectId() ); jobMap.put( entry, job ); configurationMap.put( entry, jobConfiguration ); }